-
Notifications
You must be signed in to change notification settings - Fork 505
fix/wsi-viewport-preserve-zoom-on-resize #2807
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
Closed
katyayni1999000
wants to merge
1
commit into
cornerstonejs:main
from
katyayni1999000:fix/wsi-viewport-preserve-zoom-on-resize
+22
−0
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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.
🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win
Guard against zero dimensions and invalid extents to prevent OpenLayers crashes.
When the viewport container is temporarily hidden (e.g., inside a collapsed panel or
display: none) or initialized with zero dimensions,map.getSize()returns[0, 0]. Since arrays are truthy in JavaScript, the code proceeds and computesrelativeZoomasInfinity(due to division by zero ingetResolutionForExtent).When the container is later shown and resized, dividing by
Infinityleads toview.setResolution(0), which corrupts the OpenLayers view state. Additionally,view.getProjection().getExtent()can returnnull, which causesgetResolutionForExtentto throw an error.Ensure the sizes strictly have width and height
> 0and that the resultingrelativeZoomis finite before applying it.🔒️ Proposed fix to add robust boundary checks
📝 Committable suggestion
🧰 Tools
🪛 GitHub Actions: Docusaurus Build / 0_docusaurus-build.txt
[error] 461-461: TypeScript (tsc) failed with TS2339: Property 'getSize' does not exist on type 'WSIMapLike'.
🪛 GitHub Actions: Docusaurus Build / docusaurus-build
[error] 461-461: TypeScript (tsc) failed: TS2339: Property 'getSize' does not exist on type 'WSIMapLike'.
🪛 GitHub Actions: Validate ESM Packaging / 1_build-packages.txt
[error] 461-461: TypeScript (tsc) failed with TS2339: Property 'getSize' does not exist on type 'WSIMapLike'.
🪛 GitHub Actions: Validate ESM Packaging / build-packages
[error] 461-461: TypeScript compilation failed (tsc). TS2339: Property 'getSize' does not exist on type 'WSIMapLike'.
🤖 Prompt for AI Agents