-
Notifications
You must be signed in to change notification settings - Fork 890
fix: plotly shapes not clearing when removed from figure #7974
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
Conversation
When shapes were added to a Plotly figure and then removed, they would persist visually even though the figure data no longer contained them. The fix changes the layout update logic to only preserve user-interaction values (dragmode, xaxis, yaxis) from the previous layout, while taking everything else from the new figure. Also refactored the layout management into a separate `usePlotlyLayout` hook with pure utility functions, enabling unit testing without rendering. Closes #7964
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Fixes a Plotly rendering bug where shapes could remain visible after being removed from the figure by changing how layout state is preserved across figure updates.
Changes:
- Adjust layout update behavior to only persist user-interaction layout fields (dragmode/xaxis/yaxis) when the figure prop changes.
- Refactor Plotly layout management into a dedicated
usePlotlyLayouthook with pure helper functions. - Add unit tests and a Plotly smoke test reproducer for the shapes-clearing scenario.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| marimo/_smoke_tests/plotly/shapes.py | Adds a smoke-test reproducer for adding/removing Plotly shapes. |
| frontend/src/plugins/impl/plotly/usePlotlyLayout.ts | Introduces a new hook + utilities to manage layout preservation across figure updates. |
| frontend/src/plugins/impl/plotly/tests/usePlotlyLayout.test.ts | Adds unit coverage for the new layout utilities (including #7964 scenario). |
| frontend/src/plugins/impl/plotly/PlotlyPlugin.tsx | Integrates the new hook and updates reset behavior to clear persisted plugin state. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.19.7-dev7 |
When shapes were added to a Plotly figure and then removed, they would persist visually even though the figure data no longer contained them.
The fix changes the layout update logic to only preserve user-interaction values (dragmode, xaxis, yaxis) from the previous layout, while taking everything else from the new figure.
Also refactored the layout management into a separate
usePlotlyLayouthook with pure utility functions, enabling unit testing without rendering.Closes #7964