Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [UNRELEASED]

* `datetime.date()` values are properly JSON serialized. (#204)
* Callbacks on a plotly `FigureWidget` are now retained for recent versions of plotly. (#207, thanks @simeonschwarzenberg)

## [0.6.2] - 2025-05-21

Expand Down
10 changes: 8 additions & 2 deletions shinywidgets/_render_widget_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ def set_layout_defaults(widget: Widget) -> Tuple[Widget, bool]:

# Plotly provides it's own layout API (which isn't a subclass of ipywidgets.Layout)
if pkg == "plotly":
from plotly.graph_objs import Layout as PlotlyLayout # pyright: ignore
from plotly.graph_objs import Layout as PlotlyLayout
from plotly.basewidget import BaseFigureWidget

if isinstance(layout, PlotlyLayout):
if layout.height is not None:
Expand All @@ -190,7 +191,12 @@ def set_layout_defaults(widget: Widget) -> Tuple[Widget, bool]:
if fill:
widget._config = {"responsive": True, **widget._config} # type: ignore

widget.layout = layout
if isinstance(widget, BaseFigureWidget):
# Reassigning the layout to a FigureWidget drops installed callbacks;
# use native update_layout instead.
widget.update_layout(layout)
else:
widget.layout = layout

# altair, confusingly, isn't setup to fill it's Layout() container by default. I
# can't imagine a situation where you'd actually want it to _not_ fill the parent
Expand Down