You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[a11y] Lightbox: Focus leaks outside the overlay during keyboard navigation (Tab key) #75801
[Block] GalleryAffects the Gallery Block - used to display groups of images[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended
When navigating a lightbox gallery using keyboard (Tab / Shift+Tab), focus escapes outside the lightbox overlay and becomes invisible — the focus indicator disappears entirely, leaving the user with no visual feedback on where they are on the page.
Expected behavior:
Focus cycles only within the lightbox (close button, navigation arrows). When the last focusable element is reached, focus should wrap back to the first one.
Step-by-step reproduction instructions
Add a Gallery block to a page/post.
Enable the lightbox option for the gallery.
Open the published page and open the lightbox by clicking on an image.
Navigate using the Tab key repeatedly.
Screenshots, screen recording, code snippet
No response
Environment info
Gutenberg version: 22.6 RC1, 22.8.-nightly
Active theme: TT5
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
Please confirm which theme type you used for testing.
Thanks @Gierand for raising the issue, I was able to replicate the issue on Gutenberg 22.6 RC2 with TT5.
Video:
75801.-.Issue.Replication.mov
Root Cause
The lightbox overlay is rendered once per lightbox-enabled image instead of once per page. Each call to block_core_image_render_lightbox() registers a new wp_footer callback using an anonymous closure. WordPress treats each closure as a unique callback, so the overlay HTML is printed multiple times.
For a gallery with 3 images, you get 3 identical .wp-lightbox-overlay divs in the DOM:
Screenshot:
This was introduced in #62906 (676fabe8cd), which changed the original named function reference to an anonymous closure during the gallery lightbox work. The previous code was already correct:
// Before #62906 — correct, idempotent (WordPress deduplicates string callbacks)add_action( 'wp_footer', 'block_core_image_print_lightbox_overlay' );
// After #62906 — broken (each closure is a unique callback → duplicates)$overlay_callback = function () {
block_core_image_print_lightbox_overlay();
};
add_action( 'wp_footer', $overlay_callback );
Fix
PHP — Restore the named function reference (1-line change):
[Block] GalleryAffects the Gallery Block - used to display groups of images[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended
Activity
namankhare commentedon Feb 24, 2026
Thanks @Gierand for raising the issue, I was able to replicate the issue on Gutenberg 22.6 RC2 with TT5.
Video:
75801.-.Issue.Replication.mov
Root Cause
The lightbox overlay is rendered once per lightbox-enabled image instead of once per page. Each call to block_core_image_render_lightbox() registers a new wp_footer callback using an anonymous closure. WordPress treats each closure as a unique callback, so the overlay HTML is printed multiple times.
For a gallery with 3 images, you get 3 identical .wp-lightbox-overlay divs in the DOM:
Screenshot:
This was introduced in #62906 (676fabe8cd), which changed the original named function reference to an anonymous closure during the gallery lightbox work. The previous code was already correct:
Fix
Working video:
75801.-.Fix.mov
I have raised a PR with above changes: #75852
cc: @t-hamano
Gierand commentedon Feb 24, 2026
@namankhare,
Thank you for taking care of this issue.