Skip to content

Conversation

cpsievert
Copy link
Collaborator

@cpsievert cpsievert commented May 21, 2025

Follow up (in a sense) to #191 and #195. Now that we only close widgets (server-side) when they're created in an output context, it is technically possible to render the same widget repeatedly in a render function, which leads to duplicated views of that widget. For example, clicking the button here will generate duplicate views:

import plotly.express as px
from shiny.express import input, ui

from shinywidgets import as_widget, render_plotly

ui.input_action_button("redraw", "Redraw")

p = px.histogram(
    px.data.tips(),
    x="total_bill",
)
w = as_widget(p)

@render_plotly
def plot():
    input.redraw()
    return w

This PR fixes that issue by resurrecting some cleanup code we had before doing server-side cleanup

@cpsievert cpsievert changed the title Eliminate the possibility of Shiny.OutputBinding.renderValue() producing multiple widget views Eliminate the possibility of a single render_widget output from keeping a view of prior renders May 21, 2025
@cpsievert cpsievert merged commit 923e108 into main May 21, 2025
5 checks passed
@cpsievert cpsievert deleted the fix/view-cleanup branch May 21, 2025 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant