Skip to content

Gallery: default lightbox nav to Both and add icon-only focus labels#77686

Open
vishnupprajapat wants to merge 1 commit intoWordPress:trunkfrom
vishnupprajapat:fix/77545-gallery-lightbox-a11y-defaults
Open

Gallery: default lightbox nav to Both and add icon-only focus labels#77686
vishnupprajapat wants to merge 1 commit intoWordPress:trunkfrom
vishnupprajapat:fix/77545-gallery-lightbox-a11y-defaults

Conversation

@vishnupprajapat
Copy link
Copy Markdown
Contributor

What?

Closes #77545

This PR updates Gallery lightbox navigation defaults and improves discoverability for icon-only controls.

Why?

In lightbox, icon-only navigation can make control intent less obvious, especially for keyboard users. The issue discussion converged on two improvements:

  1. Make new Gallery blocks default to Both for navigation buttons.
  2. Keep icon-only mode available, but show visible labels on hover/focus-visible to improve clarity without forcing permanent text labels.

How?

  1. Changed the Gallery navigationButtonType default from icon to both.
  2. Updated Gallery inspector reset/deselect behavior to use both as baseline.
  3. Updated server-side lightbox context fallback to both for consistency.
  4. Added CSS tooltip-style visible labels for icon-only controls (Close, Previous, Next) on:
    • :hover (hover-capable devices)
    • :focus-visible (keyboard focus)
  5. Updated integration fixtures that assert default Gallery attributes.
  6. Added focused e2e coverage for:
    • default Both behavior in lightbox
    • icon-only label visibility on keyboard focus

Testing Instructions

  1. Start env: npm run wp-env start.
  2. Create a new post.
  3. Insert a Gallery block with at least 2 images.
  4. Ensure images open in lightbox (Enlarge on click enabled).
  5. Publish and view post.
  6. Click a gallery image to open lightbox.
  7. Confirm default behavior shows text labels (Both mode):
    • Close text is visible.
    • Next/Previous text is visible.
  8. Go back to editor and set Navigation button type to Icon.
  9. Update post and reload front end.
  10. Open lightbox again.
  11. Confirm static text labels are hidden in icon-only mode.
  12. Hover controls (desktop) and confirm visible label appears.

Testing Instructions for Keyboard

  1. Open the published post.
  2. Open lightbox from a gallery image.
  3. Press Tab to move focus to lightbox controls.
  4. On focused icon-only control, verify visible label appears (focus-visible state).
  5. Continue tabbing through Close/Previous/Next controls and verify labels appear on focus.
  6. Press Enter/Space to trigger control actions.
  7. Press Esc to close lightbox.

Screenshots or screencast

Before After
Icon-only controls had no visible hover/focus label in lightbox. Default is Both; icon-only shows visible labels on hover/focus-visible.

Use of AI Tools

I used GitHub Copilot (GPT-5.3-Codex) to assist with drafting code changes. I reviewed, validated, and take responsibility for all final changes.

@github-actions github-actions Bot added the [Package] Block library /packages/block-library label Apr 27, 2026
@github-actions
Copy link
Copy Markdown

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: vishnupprajapat <vishnuprajapat@git.wordpress.org>
Co-authored-by: kedarjoyner <kjoyner@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@t-hamano t-hamano added [Type] Enhancement A suggestion for improvement. Needs Design Feedback Needs general design feedback. Needs Accessibility Feedback Need input from accessibility [Block] Gallery Affects the Gallery Block - used to display groups of images labels Apr 28, 2026
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 Needs Accessibility Feedback Need input from accessibility Needs Design Feedback Needs general design feedback. [Package] Block library /packages/block-library [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gallery block - Improve accessibility of lightbox controls

2 participants