fix(ui): prevent NaN aspect ratio in createThumbnail on svg files #10488
+2
−2
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.
What?
This PR fixes an issue for Firefox users encountered when drag-and-dropping an svg file into the BulkUpload drawer dropzone where, because of both img.width and img.height being 0, aspect ratio becomes NaN due to division by zero.
Why?
To prevent a runtime error for Firefox users and to render an appropriate thumbnail as expected.
How?
By logically checking that the divisor, in this case
img.height
is not zero, and setting a fallback if so.Notes:
Before:
https://github.com/user-attachments/assets/e1b12a55-551a-4fcb-9df7-dabde87729b6
After:
https://github.com/user-attachments/assets/52791919-b657-4580-ac37-ca4be749c9a7