Skip to content
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

fix(ui): prevent NaN aspect ratio in createThumbnail on svg files #10488

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

akhrarovsaid
Copy link
Contributor

@akhrarovsaid akhrarovsaid commented Jan 10, 2025

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:

  • This is a follow-up to an issue I found while authoring fix(ui): remove clearData call in dropzone drop handler #10475 which shows up as a runtime error in the below videos as well.
  • As a result of this PR, I was reminded of another bug where thumbnails were not correctly updated if the BulkUpload EditForm contained only some successful files saved.

Before:
https://github.com/user-attachments/assets/e1b12a55-551a-4fcb-9df7-dabde87729b6

After:
https://github.com/user-attachments/assets/52791919-b657-4580-ac37-ca4be749c9a7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant