plotly/plotly.js#7659 fix: preserve z-indexed subplots during relayout for correct pan/zoom
Fixes a bug with the first pan/zoom after page load, when traces have different zorder values: some traces are not redrawn until the pan/zoom completes (while others are). All traces are redrawn continuously during subsequent pans/zooms, as expected. This is particularly noticeable in react-plotly.js, which calls Plotly.Plots.resize() after mount.
Root cause: When relayout is called (e.g., during resize), supplyDefaults resets _plots via linkSubplots, losing z-indexed subplots (e.g., xyz2, xyz3). Since relayout doesn't trigger drawFramework, they aren't recreated, causing updateSubplots in dragbox.js to miss them during pan/zoom.
Fix:
- In
linkSubplots(plots.js): preserve z-indexed subplots fromoldSubplots - In
updateSubplots(dragbox.js): include z-indexed subplots from_plots
bug.mp4
Live before/after comparison: https://runsascoded.github.io/plotly.js/
To reproduce the bug:
- Open the Before Fix demo
- Drag the chart to pan horizontally
- First drag: one trace (blue) moves with the grid, but the other trace (red) stays frozen
- Release and drag again
- Second drag: both traces move correctly together
- Compare with After Fix — first drag works correctly
- Existing
cartesian_interacttests pass - Manual testing with react-plotly.js confirms fix
- CI tests
🤖 Generated with Claude Code