File tree 2 files changed +12
-2
lines changed
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,10 @@ All notable changes to shinywidgets will be documented in this file.
5
5
The format is based on [ Keep a Changelog] ( https://keepachangelog.com/en/1.0.0/ ) ,
6
6
and this project adheres to [ Semantic Versioning] ( https://semver.org/spec/v2.0.0.html ) .
7
7
8
+ ## [ UNRELEASED]
9
+
10
+ * Fixed an issue where ` @render_widget ` would sometimes incorrectly render a new widget without removing the old one. (#167 )
11
+
8
12
## [ 0.4.1] - 2024-12-17
9
13
10
14
* Fixed a Python 3.9 compatibility issue.
Original file line number Diff line number Diff line change 21
21
from shiny import Session , reactive
22
22
from shiny .http_staticfiles import StaticFiles
23
23
from shiny .reactive ._core import get_current_context
24
- from shiny .session import get_current_session , require_active_session
24
+ from shiny .session import get_current_session , require_active_session , session_context
25
25
26
26
from ._as_widget import as_widget
27
27
from ._cdn import SHINYWIDGETS_CDN_ONLY , SHINYWIDGETS_EXTENSION_WARNING
37
37
38
38
if TYPE_CHECKING :
39
39
from typing import TypeGuard
40
+
40
41
from traitlets .traitlets import Instance
41
42
42
43
@@ -129,7 +130,12 @@ def _cleanup_session_state():
129
130
# If we're in a reactive context, close this widget when the context is invalidated
130
131
if has_current_context ():
131
132
ctx = get_current_context ()
132
- ctx .on_invalidate (lambda : w .close ())
133
+
134
+ def on_close ():
135
+ with session_context (session ):
136
+ w .close ()
137
+
138
+ ctx .on_invalidate (on_close )
133
139
134
140
# Keep track of what session this widget belongs to (so we can close it when the
135
141
# session ends)
You can’t perform that action at this time.
0 commit comments