fix: preserve z-indexed subplots during relayout for correct pan/zoom
#7659
+25
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a bug where pan/zoom fails on the first interaction when traces have different
zordervalues. On first drag, one trace moves with the grid while the other stays frozen in place. The second pan (and all subsequent pans) work correctly — both traces move together as expected. This is particularly noticeable in react-plotly.js, which callsPlotly.Plots.resize()after mount.Root cause: When
relayoutis called (e.g., during resize),supplyDefaultsresets_plotsvialinkSubplots, losing z-indexed subplots (e.g.,xyz2,xyz3). Sincerelayoutdoesn't triggerdrawFramework, they aren't recreated, causingupdateSubplotsindragbox.jsto miss them during pan/zoom.Fix:
linkSubplots(plots.js): preserve z-indexed subplots fromoldSubplotsupdateSubplots(dragbox.js): include z-indexed subplots from_plotsDemo
bug.mp4
Live before/after comparison: https://runsascoded.github.io/plotly.js/
To reproduce the bug:
Test plan
cartesian_interacttests pass🤖 Generated with Claude Code