Skip to content

Fix: Restore visible focus state to the button-inside search field - #141

Open
CookieDarb wants to merge 2 commits into
WordPress:trunkfrom
CookieDarb:fix/search-focus
Open

CookieDarb wants to merge 2 commits into
WordPress:trunkfrom
CookieDarb:fix/search-focus

Conversation

@CookieDarb

Copy link
Copy Markdown
Contributor

Description

Closes #140

Restores a visible keyboard focus state on the Search block when configured with the button inside the field.

Why?

When the Search block uses the button-inside layout, WordPress Core removes the default input outline (:where(.wp-block-search__button-inside .wp-block-search__inside-wrapper) .wp-block-search__input:focus { outline: none; }) without supplying a replacement focus state on the container. As a result, keyboard users navigating into the input field see no visible focus indicator, failing WCAG 2.4.7 (Focus Visible).

How?

  • theme.json:
    • Added native focus ring styles to .wp-block-search__inside-wrapper when the child input receives focus (:has(.wp-block-search__input:focus)).
    • Uses outline: -webkit-focus-ring-color auto 1px (and standard AccentColor fallback) with 0 offset, matching the native browser focus indicator displayed on all other form fields throughout the theme without creating double outlines when tabbing onto the search button

Screencast

Before

Before-search-focus-fix.mov

After

After-search-focus-fix.mov

Testing Instructions

  1. Navigate to a page featuring a button-inside search block (e.g., search results at /?s=hello or the overlay menu).
  2. Press Tab to navigate keyboard focus into the search input field.
  3. Verify that the search container displays a visible, native focus ring.
  4. Press Tab again to move focus onto the search button.
  5. Verify that the outer container focus ring turns off and the button displays its own button focus state without double or nested focus rings.

Use of AI Tools

AI assistance: Yes
Tool(s): Antigravity
Model(s): Gemini
Used for: Reviewing the existing implementation and suggesting the changes. Final decisions and edits were made by me.

@github-actions

github-actions Bot commented Oct 8, 2026 •

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.

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: CookieDarb <sakshamsharma5@git.wordpress.org>
Co-authored-by: rvpatel <ravipatel@git.wordpress.org>
Co-authored-by: MaggieCabrera <onemaggie@git.wordpress.org>

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@github-actions github-actions Bot added the [Area] Global Styles Issues or PRs that touch theme.json or the base stylesheet. label Oct 8, 2026
@rvpatel

rvpatel commented Oct 22, 2026 •

Copy link
Copy Markdown

Tested on WordPress 7.2-beta1 with this PR on current Ipsum trunk (merges cleanly), on Windows 11, Edge 142.

Check Result
Focus in the button-inside search field (/?s=hello) ✅ Clear focus ring around the whole box (before: no visible change)
Focus moved to the search button ✅ Box ring goes away, only the button shows focus, no double ring
Same in the After Hours colour variation ✅ Ring clearly visible on the dark background
Before After
Field focused Before: field focused, no visible focus After: field focused, focus ring around the box
Field focused, After Hours Before: After Hours, no visible focus After: After Hours, white focus ring
Button focused — After: button focused, box ring removed
Screenshots from headless Edge, with focus set by script (same :focus styles as tabbing). Not tested yet: Firefox, and the search in the navigation overlay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Area] Global Styles Issues or PRs that touch theme.json or the base stylesheet.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Search field with the button inside has no visible focus state

2 participants