Skip to content

Conversation

@mscolnick
Copy link
Contributor

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

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
@vercel
Copy link

vercel bot commented Jan 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
marimo-docs Ready Ready Preview, Comment Jan 26, 2026 6:19pm

Request Review

Light2Dark
Light2Dark previously approved these changes Jan 26, 2026
Copy link
Contributor

Copilot AI left a 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 usePlotlyLayout hook 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.

@mscolnick mscolnick added the bug Something isn't working label Jan 26, 2026
@mscolnick mscolnick merged commit 511fc44 into main Jan 26, 2026
44 of 45 checks passed
@mscolnick mscolnick deleted the ms/7964 branch January 26, 2026 19:21
@github-actions
Copy link

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.19.7-dev7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plotly charts not clearing up shapes after creation

3 participants