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: Adding images to gallery removes all existing images #33769

Closed
3 tasks done
pattyok opened this issue Jul 29, 2021 · 7 comments · Fixed by #35070
Closed
3 tasks done

Gallery Block: Adding images to gallery removes all existing images #33769

pattyok opened this issue Jul 29, 2021 · 7 comments · Fixed by #35070
Assignees
Labels
[Block] Gallery Affects the Gallery Block - used to display groups of images [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@pattyok
Copy link

pattyok commented Jul 29, 2021

Is there an existing issue for this?

  • I have searched the existing issues

Have you tried deactivating all plugins except Gutenberg?

  • I have tested with all plugins deactivated.

Have you tried replicating the bug using a default theme e.g. Twenty Twenty?

  • I have tested with a default theme.

Description

When adding images to an existing gallery block, any existing images disappear. I have verified that this issue was introduced in 5.8. I tested on the same site prior to upgrading from 5.7 and it worked as expected.

This appears to be an issue with the <MediaUpload> component as I found the bug when I was working on my own block using that component.

Step-by-step reproduction instructions

  1. Add a Gallery Block to a page or post
  2. Add some images to the gallery
  3. Click the Media Library link to add more images to the gallery
  4. Select a new image to add to the gallery
  5. Click Add to Gallery
  6. The edit screen opens with only the new images, the existing images are gone

Expected Behavior

Would expect that adding to gallery retains the existing images

Current Behavior

When adding to the gallery the existing images disappear

IF you visit the Edit Gallery screen prior to adding images, it works as expected, though that's not an intuitive workflow..

Screenshots or screen recording (optional)

galleryissue

Code snippet (optional)

No response

WordPress Information

WP 5.8

Gutenberg Information

Gutenberg not installed

What browsers are you seeing the problem on?

Chrome

Device Information

Desktop

Operating System Information

MacOS 11.4

@talldan talldan added [Block] Gallery Affects the Gallery Block - used to display groups of images [Type] Bug An existing feature does not function as intended labels Jul 30, 2021
@talldan
Copy link
Contributor

talldan commented Jul 30, 2021

Thanks for reporting. I could reproduce this. There also seems to be a bug with the Gutenberg plugin where the file picker is opened every time I click the Media Library button. 🤔

@sabernhardt
Copy link
Contributor

Thanks! This was also reported on Trac 53835.

@pento pento added this to the WordPress 5.8.1 milestone Aug 6, 2021
@pento
Copy link
Member

pento commented Aug 6, 2021

I've been able to reproduce this issue. I've also found a workaround:

  1. Add a Gallery Block to a page or post
  2. Add some images to the gallery
  3. Click the Media Library link to add more images to the gallery
  4. On the left side of the Media Library modal, click Edit gallery
  5. On the left side of the Media Library modal, click Add to gallery
  6. Select a new image to add to the gallery
  7. Click Add to Gallery
  8. The gallery in the post now correctly contains the old images, and the new image.

@mpeshev
Copy link

mpeshev commented Aug 13, 2021

Still not sure why it isn't pulling the right attachments from the previous gallery, but I found that the view only contains the new entries before rendering the new modal instead of pulling the previous collection too.

It may be related to the trigger chaining and the necessity to pull the entries from Edit gallery and appending them as Attachments in the corresponding view.

@desrosj
Copy link
Contributor

desrosj commented Aug 31, 2021

With WordPress 5.8.1 RC due out in less than 24 hours and no proposed fix, I've moved this to the 5.8.2 milestone.

@glendaviesnz
Copy link
Contributor

There also seems to be a bug with the Gutenberg plugin where the file picker is opened every time I click the Media Library button. 🤔

The issue of the file picker opening is noted in this issue #34099 - initially closed thinking it was a duplicate of this one, but probably worth listing as a separate issue in case it is a separate fix to the issue of the existing images being lost

@andrewserong
Copy link
Contributor

I've come up with a fix in #35070 that should resolve this issue — it's a bit of a workaround due to how the GalleryAdd controller works in the media library, but hopefully it restores the expected behaviour.

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 [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
8 participants