Skip to content

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

Closed

Description

@afercia

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

Activity

  1. added
    [Type] Bug
    [Block] Image
    [Feature] Interactivity API
    on Oct 6, 2023
  2. self-assigned this
    on Oct 6, 2023
  3. added
    [Status] In Progress
    on Oct 6, 2023
  4. moved this to Needs Dev / Todo in WordPress 6.4 Editor Taskson Oct 6, 2023
  5. annezazu commented on Oct 6, 2023

    @annezazu
    Contributor

    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

  6. artemiomorales commented on Oct 6, 2023

    @artemiomorales
    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.

  7. annezazu commented on Oct 7, 2023

    @annezazu
    Contributor

    Thanks for diving in 🙌🏼

  8. moved this from Needs Dev / Todo to In Progress in WordPress 6.4 Editor Taskson Oct 7, 2023
  9. afercia commented on Oct 9, 2023

    @afercia
    ContributorAuthor

    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?

  10. moved this to Development Feedback in Image Lightboxon Oct 11, 2023
  11. moved this from Development Feedback to Done in Image Lightboxon Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

[Block] Image[Feature] Interactivity API[Status] In Progress[Type] Bug

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions