Fix image panning constraints for wide/short images in plot viewer #17050
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.
Problem
When viewing wide but short images (or any extreme aspect ratio) in the plot viewer, users experienced panning constraints that prevented them from viewing the entire image when zoomed in. Specifically:
This issue was reported in #[issue_number] with a detailed reproduction showing matplotlib time series plots that are very wide but short.
Root Cause
The
ReactSVGPanZoomcomponent insrc/webviews/webview-side/react-common/svgViewer.tsxwas using the default value for thepreventPanOutsideproperty, which restricts image panning to keep content within the viewport boundaries. While this works well for images that roughly fit the viewport, it creates problems for images with extreme aspect ratios where the constrained dimension becomes over-restricted.Solution
Added
preventPanOutside={false}to theReactSVGPanZoomcomponent to allow free panning of images in all directions. This enables users to view all parts of any image regardless of aspect ratio, without artificial boundary restrictions.The change is minimal and surgical - a single boolean property addition that doesn't affect any other functionality. Users can still easily recenter or reset the view using the existing toolbar controls (pan, zoom in, zoom out).
Testing
Impact
This fix improves the user experience for viewing plots of any aspect ratio, particularly benefiting users who create wide time series plots or other visualizations that don't match typical screen dimensions.
Fixes #[issue_number]
Original prompt
Fixes #9349
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.