-
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
[Mobile] - Gallery block - Fix getMediaItems #63426
Conversation
Size Change: +2.13 kB (+0.12%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
@geriux The error message is now gone, but I still experience the inability to add the same image twice and the occasional unexpected position changes when following the steps shared in wordpress-mobile/gutenberg-mobile#6973 (review). This occurs in both the iOS and Android builds. Do you experience this as well? |
Hey @dcalhoun thanks for testing this change!
Yes, I just reproduced it. I was always adding photos from my device and not using the WordPress Media Library. 😅 So, this is also happening in the web editor. The only difference is that in the native WordPress media library, we are not highlighting the selected media, so you are able to select it, but then the code filters it out. In the web UI, you see already added images as selected: I believe we had this functionality before the recent media library updates 🤔 As for the images changing their position, this issue is also occurring in the web editor. This happens by adding an image from the Image block appender, where you are able to insert an image that’s already added to the Gallery. When a duplicated image is added, they will change their position to be next to each other because there's a sorting part in the code. We should improve the WordPress Media Library in the host apps to avoid adding duplicate images by highlighting the ones that are already added. |
Ah, that makes sense. Thank you for investigating.
I am unable to reproduce the unexpected gallery item re-ordering in the web editor. However, I suppose the issue within the native editor might only be significantly disruptive when modifying a large gallery. The user can recover from this bug by manually re-ordering the gallery items after uploading. |
Yeah, I agree they could just move the position of the image. This is how I was able to reproduce it: GalleryWebBug.mov |
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.
I didn’t find the culprit of this regression, but after some investigation, I confirmed that the data was being fetched correctly, yet it wasn’t being stored in the state.
Very interesting. Thank you for investigating and sharing your findings.
The test plan succeeded for me on an iPhone SE and Galaxy S20. 🚀
* Mobile - Fix getMediaItems * Rearrange conditions for parseResponse * Fix response conditions Co-authored-by: geriux <geriux@git.wordpress.org> Co-authored-by: dcalhoun <dpcalhoun@git.wordpress.org>
* Mobile - Fix getMediaItems * Rearrange conditions for parseResponse * Fix response conditions Co-authored-by: geriux <geriux@git.wordpress.org> Co-authored-by: dcalhoun <dpcalhoun@git.wordpress.org>
Related PRs:
What?
This PR addresses a regression in the Gallery block that was causing error notices to appear in certain scenarios. Additionally, it prevents the images from randomly changing their position when new images are added.
Why?
To provide a good user experience when adding new images by preventing random errors and unexpected behavior.
How?
I didn’t find the culprit of this regression, but after some investigation, I confirmed that the data was being fetched correctly, yet it wasn’t being stored in the state.
This was causing the useGetMedia hook to not return the expected data of the images.
By looking more into the code, I realized the fetch promise was being intercepted by a catch, so no data was being stored.
The error was happening in fetchAllMiddleware, where parseResponse is called and expects to have a Response parameter in JSON format.
After all this, I decided to update the native implementation of fetchHandler and update how it parses the response.
Now it will return a
Response
object if theparse
parameter is set tofalse
.Testing Instructions
Note
Please use the following builds to test:
Steps provided from another PR review:
Testing Instructions for Keyboard
No testing is needed.
Screenshots or screencast
GalleryBugBefore.mov
GalleryBugAfter.mov