Skip to content

Eliminate the possibility of a single render_widget output from keeping a view of prior renders #196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

* Eliminate the possibility of a single `@render_widget` output from keeping a view of prior renders. (#196)

## [0.6.1] - 2025-05-21

* Fixed an issue introduced by v0.6.0 where cleanup wasn't happening when it should be. (#195)
Expand Down
8 changes: 8 additions & 0 deletions js/src/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ class IPyWidgetOutput extends Shiny.OutputBinding {
const view = await manager.create_view(model, {});
await manager.display_view(view, {el: el});

// Don't allow more than one .lmWidget container, which can happen
// when the view is displayed more than once
// N.B. It's probably better to get view(s) from m.views and .remove() them,
// but empirically, this seems to work better
while (el.childNodes.length > 1) {
el.removeChild(el.childNodes[0]);
}

// The ipywidgets container (.lmWidget)
const lmWidget = el.children[0] as HTMLElement;

Expand Down
Loading