Currently, useResizeHandler only responds to window.resize events.
This works when the browser viewport changes, but it does not cover layout changes that resize the plot without resizing the window.
For example, if a page contains a collapsible sidebar and a responsive plot in the same page, toggling the sidebar changes the space available to the plot, but no window.resize event is fired. The plot therefore keeps its previous size until Plotly.Plots.resize() is called manually.
Would it make sense for useResizeHandler to react to changes in the rendered plot element's size instead of only listening to window.resize?
One possible approach would be to use ResizeObserver when available, while keeping the existing window.resize listener as a fallback.
Currently,
useResizeHandleronly responds towindow.resizeevents.This works when the browser viewport changes, but it does not cover layout changes that resize the plot without resizing the window.
For example, if a page contains a collapsible sidebar and a responsive plot in the same page, toggling the sidebar changes the space available to the plot, but no
window.resizeevent is fired. The plot therefore keeps its previous size untilPlotly.Plots.resize()is called manually.Would it make sense for useResizeHandler to react to changes in the rendered plot element's size instead of only listening to
window.resize?One possible approach would be to use ResizeObserver when available, while keeping the existing
window.resizelistener as a fallback.