plotly / plotly/react-plotly.js
`useResizeHandler` does not respond to container layout changes
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.1k
- Forks
- 138
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 4
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the useResizeHandler implementation and trace how it currently subscribes to window.resize. Check the existing tests around resize handling, then verify that changes to the rendered plot element trigger resizing while the window-resize fallback still works. Done means collapsible-layout changes resize the plot without a manual Plotly.Plots.resize() call.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- data-visualization, frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100