Gallery Lightbox: Prevent image click from closing the dialog when navigation is enabled#78898
Open
i-am-chitti wants to merge 1 commit into
Open
Gallery Lightbox: Prevent image click from closing the dialog when navigation is enabled#78898i-am-chitti wants to merge 1 commit into
i-am-chitti wants to merge 1 commit into
Conversation
|
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. |
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Closes #78869
Prevents clicking or tapping the expanded image from closing the lightbox when navigation controls are present in a gallery lightbox.
Why?
When a gallery lightbox is open, clicking anywhere on the overlay — including directly on the expanded image — closes it. For a standalone image lightbox this is a reasonable affordance, but in a gallery with navigation controls it causes unexpected dismissals.
On touch devices the impact is significant: the only visible controls are the navigation buttons, so a user tapping the image to inspect detail, or slightly mis-tapping while reaching for a nav button, loses their place in the gallery with no recovery other than reopening and navigating back.
The behavior was inherited from the single-image lightbox implementation when gallery navigation was introduced in #62906, without being re-evaluated in the context of a navigable gallery.
How?
Added a
handleImageContainerClickaction inview.jsthat callsevent.stopPropagation()whenstate.hasNavigationis true. This follows the same pattern the Previous/Next navigation buttons already use to prevent accidental closes.The handler is attached to both
.lightbox-image-containerelements in the PHP template. Ahas-navigationCSS class is also toggled on the overlay to resetcursor: zoom-outtocursor: defaulton the image container, so the cursor no longer implies the image is clickable-to-close.the image still closes the dialog.
continue to close the gallery lightbox.
Testing Instructions
→ Expected: Nothing happens. The lightbox stays open.
→ Expected: Lightbox closes.
→ Expected: Lightbox closes.
the image.
→ Expected: Lightbox closes.
mobile emulation
Single-image regression check:
11. Insert a standalone Image block (not in a Gallery) and enable
Lightbox.
12. Open the lightbox and click the image.
→ Expected: Lightbox still closes (existing behavior unchanged).
Testing Instructions for Keyboard
image thumbnail.
buttons; confirm focus is trapped inside the overlay.
Screenshots or screencast
Before
Screen.Recording.2026-06-03.at.12.44.45.PM.mp4
After
Screen.Recording.2026-06-03.at.12.45.54.PM.mp4
Use of AI Tools
This PR was developed with the assistance of GitHub Copilot. Each change was reviewed and validated by me.