From 234c66659976096b52b44f702dcfc0e4f9f6ce92 Mon Sep 17 00:00:00 2001 From: Carson Date: Wed, 21 May 2025 17:34:53 -0500 Subject: [PATCH 1/2] Properly cleanup when the Widget is initialized by an implicit as_widget() call --- shinywidgets/_render_widget_base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/shinywidgets/_render_widget_base.py b/shinywidgets/_render_widget_base.py index fb6ac52..5e8021a 100644 --- a/shinywidgets/_render_widget_base.py +++ b/shinywidgets/_render_widget_base.py @@ -71,7 +71,10 @@ def __init__( async def render(self) -> Jsonifiable | None: with WidgetRenderContext(self.output_id): - value = await self.fn() + return await self._render() + + async def _render(self) -> Jsonifiable | None: + value = await self.fn() # Attach value/widget attributes to user func so they can be accessed (in other reactive contexts) self._value = value From cc098acd02ec214e63823d52095cf0da87fb2ead Mon Sep 17 00:00:00 2001 From: Carson Date: Wed, 21 May 2025 17:44:48 -0500 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f071fc..87906cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to shinywidgets will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [UNRELEASED] + +* Fixed an issue introduced by v0.6.0 where cleanup not happening when it should. (#195) + ## [0.6.0] - 2025-05-19 * Widgets initialized inside a `reactive.effect()` are no longer automatically removed when the effect invalidates. (#191)