Skip to content

Commit 923e108

Browse files
authored
Eliminate the possibility of a single render_widget output from keeping a view of prior renders (#196)
1 parent 31410ef commit 923e108

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to shinywidgets will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [UNRELEASED]
9+
10+
* Eliminate the possibility of a single `@render_widget` output from keeping a view of prior renders. (#196)
11+
812
## [0.6.1] - 2025-05-21
913

1014
* Fixed an issue introduced by v0.6.0 where cleanup wasn't happening when it should be. (#195)

js/src/output.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ class IPyWidgetOutput extends Shiny.OutputBinding {
103103
const view = await manager.create_view(model, {});
104104
await manager.display_view(view, {el: el});
105105

106+
// Don't allow more than one .lmWidget container, which can happen
107+
// when the view is displayed more than once
108+
// N.B. It's probably better to get view(s) from m.views and .remove() them,
109+
// but empirically, this seems to work better
110+
while (el.childNodes.length > 1) {
111+
el.removeChild(el.childNodes[0]);
112+
}
113+
106114
// The ipywidgets container (.lmWidget)
107115
const lmWidget = el.children[0] as HTMLElement;
108116

0 commit comments

Comments
 (0)