-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[RNMobile] Prevent error message from unneccesarily firing when uploading to Gallery block #46175
Conversation
The existing 'isValidFileType' function doesn't always return true when it should for native images. This is because of a difference in the way data is retrieved for images on native. This commit updates the function to account for that difference.
Size Change: +1.55 kB (0%) Total Size: 1.32 MB
ℹ️ View Unchanged
|
@geriux, would you be able to help review this? You'll see I worked around the error by changing the way the |
Sure! I'll review it now 👍 |
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.
LGTM! I tested this on both iOS and Android 🚀 Thanks for working on this fix!
As a side note, it would be amazing if we could cover this case via a unit test, especially to avoid potential regressions in the future, wdyt? In general, I'd advocate introducing a test case in unit tests every time we spot and fix a bug. This way we ensure that the same problem won't happen again in the future 😅 . |
…ding to Gallery block (#46175) This PR ensures that any valid image uploaded to the Gallery block within the mobile apps is correctly marked as valid.
* Release script: Update react-native-editor version to 1.85.0 * Release script: Update with changes from 'npm run core preios' * Add user-facing changes to CHANGELOG * Update CHANGELOG * Release script: Update react-native-editor version to 1.85.1 * Release script: Update with changes from 'npm run core preios' * [RNMobile] Prevent error message from unneccesarily firing when uploading to Gallery block (#46175) This PR ensures that any valid image uploaded to the Gallery block within the mobile apps is correctly marked as valid. * Update CHANGELOG Co-authored-by: Derek Blank <derekpblank@gmail.com>
Thanks for the note @fluiddot, I'll look into adding a unit test for this next week. |
…ding to Gallery block (WordPress#46175) This PR ensures that any valid image uploaded to the Gallery block within the mobile apps is correctly marked as valid.
* Release script: Update react-native-editor version to 1.85.0 * Release script: Update with changes from 'npm run core preios' * Add user-facing changes to CHANGELOG * Update CHANGELOG * Release script: Update react-native-editor version to 1.85.1 * Release script: Update with changes from 'npm run core preios' * [RNMobile] Prevent error message from unneccesarily firing when uploading to Gallery block (WordPress#46175) This PR ensures that any valid image uploaded to the Gallery block within the mobile apps is correctly marked as valid. * Update CHANGELOG Co-authored-by: Derek Blank <derekpblank@gmail.com>
What?
This PR ensures that any valid image uploaded to the Gallery block within the mobile apps is correctly marked as valid.
Why?
Following the updates to the Gallery block's error notices in #43946, the following error began displaying when uploading images to an existing Gallery block:
If uploading to a gallery all files need to be image formats
Note, the previous implementation of the error notices had not been supported on mobile. The referenced PR exposed a previously 'silent' issue by introducing an error notice that worked within the apps.
How?
The error began firing as the
isValidFileType
function was returningfalse
for existing images in a Gallery block on native:gutenberg/packages/block-library/src/gallery/edit.js
Lines 219 to 225 in f1dd9e1
The above function works for newly uploaded images, as those images return a
file
object similar to the following:However, on native, images that are already uploaded to a Gallery block return a
file
object similar to the following:To account for the different data that's retrieved for already-uploaded images on native, the
isValidFileType
function has been updated to gather themedia_type
details from the file's raw image data:gutenberg/packages/block-library/src/gallery/edit.js
Lines 219 to 235 in 54decbe
Testing Instructions
If uploading to a gallery all files need to be image formats
doesn't fire unexpectedly after uploading valid images.Screenshots or screencast
From these screenshots taken immediately after uploading an image to the gallery, you'll see that the first screenshot shows an error message despite the fact a valid image had been uploaded: