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

Gallery block: Media library button opens upload modal then causes an empty white modal #34099

Closed
2 tasks done
andrewserong opened this issue Aug 17, 2021 · 10 comments · Fixed by #34894
Closed
2 tasks done
Assignees
Labels
[Block] Gallery Affects the Gallery Block - used to display groups of images [Type] Bug An existing feature does not function as intended

Comments

@andrewserong
Copy link
Contributor

Description

Following Gallery block refactor PR testing instructions in: #29882, I noticed the following issue:

In a gallery that contains only a single image, if I click the Media Library button in the gallery block's placeholder, it opens the media library but then immediately also opens the upload modal. If I select an image from my computer, the media library modal renders white. When I close the modal, I can see that the image is uploaded.

What I expected:

  • The media library button not to also open the upload modal
  • In this state, if I do select an image to upload, then for the media library not to render white

Step-by-step reproduction instructions

  1. Insert a gallery with a single image in it
  2. Use the gallery's placeholder state to select the media library
  3. Notice that this also opens up the browser's upload modal
  4. Select an image to upload
  5. Notice that the media library modal now appears to be empty
  6. Closing the modal, the image appears to have been uploaded

Screenshots, screen recording, code snippet

gallery-refactor-media-library-button

Environment info

  • WP 5.8
  • Chrome browser on macOS

Pre-checks

  • I have searched the existing issues.
  • I have tested with all plugins deactivated except Gutenberg.
@andrewserong andrewserong added [Type] Bug An existing feature does not function as intended [Block] Gallery Affects the Gallery Block - used to display groups of images labels Aug 17, 2021
@glendaviesnz
Copy link
Contributor

glendaviesnz commented Aug 17, 2021

I think this might be a bug with 5.8 rather than then gallery refactor #33769 (comment)

@andrewserong
Copy link
Contributor Author

Oh, thanks Glen, didn't see that one!

@glendaviesnz
Copy link
Contributor

Going to close this as covered by #33769 (comment)

@andrewserong
Copy link
Contributor Author

Sounds good, yes just confirming that I can replicate it on a separate branch with the old gallery block, so not related to the gallery refactor 👍

@simison
Copy link
Member

simison commented Sep 14, 2021

@andrewserong @glendaviesnz you're describing two problems in this issue;

  1. upload prompt opening right after media modal opening.
  2. new images replacing old gallery

The issue you're linking covers 2nd problem, but not the first one.

The upload dialog bug happens with both old core gallery, as well with new refactored gallery. Could you have a look?

@simison simison reopened this Sep 14, 2021
@glendaviesnz
Copy link
Contributor

The issue was covered by this comment - #33769 (comment) - but probably worth having this as a separate issue so will leave it open for now

@simison simison changed the title Gallery block refactor: Media library button opens upload modal then causes an empty white modal Gallery block: Media library button opens upload modal then causes an empty white modal Sep 15, 2021
@simison
Copy link
Member

simison commented Sep 15, 2021

Thanks Glen 👍 I also updated the title to reflect that this is current bug with old gallery block as well. Will your team handle the fix?

@glendaviesnz
Copy link
Contributor

Will your team handle the fix?

Doesn't look like anyone else is picking this up in core so we have added it into our current sprint

@andrewserong andrewserong self-assigned this Sep 16, 2021
@andrewserong
Copy link
Contributor Author

Just assigning myself to this one — I'll have a go at investigating, but don't let that stop anyone else from looking, too, of course!

@andrewserong
Copy link
Contributor Author

I have a fix ready for review in #34894. It looks like the regression was introduced in #33632 when an event.stopPropagation() was removed, because the parent Placeholder element has its own click handler for the openFileDialog which then fires as well. In the fix, I've suggested we remove the parent level click handler and move it down to the upload button, but happy for feedback on the PR if folks have other ideas on how it should work 🙂

@andrewserong andrewserong removed the [Status] In Progress Tracking issues with work in progress label Sep 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Gallery Affects the Gallery Block - used to display groups of images [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants