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

Image block lightbox: setting lightbox on an image makes all following images open in the lightbox #55119

Closed
afercia opened this issue Oct 6, 2023 · 4 comments · Fixed by #55120
Assignees
Labels
[Block] Image Affects the Image Block [Feature] Interactivity API API to add frontend interactivity to blocks. [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@afercia
Copy link
Contributor

afercia commented Oct 6, 2023

Description

This can be reproduced also in WordPress core with Gutenberg disabled so is needs to be fixed before the 6.4 release.
Cc @annezazu @bph @mikachan @SiobhyB @karmatosed @hellofromtonya

When a post has more than one Image block, setting one of the image to open in the lightbox makes all following imges open in the lightbox, even if their lightbox setting is disabled.

This is clearly not the expected beheavior.

This filter rund at priority 15:

add_filter( 'render_block_core/image', 'block_core_image_render_lightbox', 15, 2 );

The filter is never removed. That means the lightbox markup and view file are added to all the blocks after the first block that has the lightbox enabled.

That also highlights that the lighbox feature has never been tested with more than one image, which is a little surprising.

Step-by-step reproduction instructions

  • Create a post.
  • Add four image blocks.
  • Set only the second image block to open the image in the lightbox.
  • Publish annd view the front end.
  • Obzerv the first image has no lightbox enabled.
  • Observe the second image has the lightbox enabled, as expected.
  • Observe the third image has the lightbox enabled: wrong.
  • Observe the fourth image has the lightbox enabled: wrong.

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@afercia afercia added [Type] Bug An existing feature does not function as intended [Block] Image Affects the Image Block [Feature] Interactivity API API to add frontend interactivity to blocks. labels Oct 6, 2023
@afercia afercia self-assigned this Oct 6, 2023
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Oct 6, 2023
@annezazu
Copy link
Contributor

annezazu commented Oct 6, 2023

Thank you for opening this. I can't replicate with 6.4-beta2 and with or without GB 16.7 with the gallery block:

images.mov

I can't with four image blocks either:

image.replicate.mov

Perhaps someone else can replicate cc @artemiomorales

@artemiomorales
Copy link
Contributor

Thanks for catching this @afercia 🙏

@annezazu I was unable to reproduce this in GB 16.7 at first, but after restarting my dev environment and rebuilding Gutenberg, I was able to see the issue, which is probably a reason this was missed.

@annezazu
Copy link
Contributor

annezazu commented Oct 7, 2023

Thanks for diving in 🙌🏼

@afercia
Copy link
Contributor Author

afercia commented Oct 9, 2023

I can't replicate with 6.4-beta2 and with or without GB 16.7 with the gallery block ... I can't with four image blocks either:

I was unable to reproduce this in GB 16.7 at first, but after restarting my dev environment and rebuilding Gutenberg, I was able to see the issue, which is probably a reason this was missed.

@artemiomorales @annezazu I see taht sometimes changes to the PHP files are not immediately applied and thus testing appears to be sometimes reliable. I have no idea why, but it seems we are at least in three who had some troubles properly testing. I wouldn't underestimate this, as a solid, reliable development environment is key for proper development and testing. Anyone know who maintaines the wp-env environment and the build process and can be pointed at this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Image Affects the Image Block [Feature] Interactivity API API to add frontend interactivity to blocks. [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
Status: Done
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants