Skip to content

Components, UI: Use focus-visible for disabled item focus rings - #86125

Merged
mirka merged 4 commits into
trunkfrom
codex/disabled-items-focus-visible
Nov 3, 2026
Merged

mirka merged 4 commits into
trunkfrom
codex/disabled-items-focus-visible

Conversation

@ciampo

@ciampo ciampo commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Follow-up to the disabled-item focus discussion in #85488.

What?

Show disabled-item focus rings only when :focus-visible matches in both Menu implementations, legacy MenuItem/DropdownMenu, and UI Select/SelectControl.

Why?

Pointer hover currently shows a focus ring on disabled menu items. UI Select also allows keyboard navigation to disabled options without showing their focus position.

How?

Use native :focus-visible with the existing focus-ring tokens. The shared legacy menu styles suppress Button's inherited ring when a disabled item has focus without matching :focus-visible.

This follows browser heuristics. After keyboard interaction, moving focus by hover can still match :focus-visible and show a ring.

Other components investigated
Components Finding
UI Menu item variants Ordinary, link, checkbox, radio, and submenu items share the changed rule.
Components Menu item variants Ordinary, checkbox, radio, and submenu items share the changed rule.
Legacy MenuItem and DropdownMenu controls Both use the changed composite-item mixin.
UI Select and SelectControl Installed Base UI 1.9.0 moves DOM focus through disabled options with arrow keys. Both inherit the added rule from the shared popup styles.
UI Combobox, Autocomplete, and searchable selects Focus stays on the input. The active option uses virtual focus, so the new :focus-visible rule does not replace its highlight.
Components ComboboxControl, FormTokenField, and Autocomplete The input or editable content keeps focus and identifies the active option with aria-activedescendant. Replacing the selected-option ring with :focus-visible would remove the keyboard cue.
Components CustomSelectControl and CustomSelectControlV2 Ariakit Select defaults to virtual focus, and default items do not opt into accessible disabled items. No matching DOM-focus rule to narrow.
Tabs and TabPanel Focus rings already use :focus-visible or data-focus-visible.
Native SelectControl and TreeSelect Option rendering belongs to the browser or operating system.

No input-modality tracking or interaction changes are added.

Testing Instructions

  1. In local Storybook, open UI Menu Rich Items with the mouse and hover Download. It should keep its disabled colors without a ring. Repeat with Components Menu Default, hovering Disabled item.
  2. Open DropdownMenu Default. Set the second control's isDisabled property to true in Storybook Controls, then hover it. It should have no ring.
  3. Open UI Select With Disabled Item and SelectControl With Disabled Option. Hover Item 2. It should have no ring.
  4. Repeat with WordPress global CSS, dark theme, RTL, and forced colors.

Testing Instructions for Keyboard

  1. Reload each story to start a fresh interaction. Tab to the trigger and press ArrowDown to open it.
  2. Use arrow keys to reach the disabled item. It should show a ring. Enter must leave the item unavailable and keep the popup open.
  3. Move to an enabled item and check its existing solid highlight. Press Escape and check that focus returns to the trigger.
Verification and limits

The production build, CSS lint, and all 166 affected existing tests passed. Browser checks passed for both Menus, legacy DropdownMenu controls, Select, and SelectControl in Chromium and WebKit. Chromium also passed with WordPress global CSS, dark theme, RTL, and emulated forced colors. The checks cover pointer-only hover, keyboard focus, unavailable activation, dismissal, and focus return. Firefox could not launch locally because it could not open its profile folder. Native Windows high contrast and screen readers were not tested.

Screenshots or screencast

Current branch, local Storybook, light theme. UI Menu Rich Items and Select With Disabled Item. Pointer hover and keyboard focus are shown after opening animations finish.

Pointer hover Keyboard focus
UI Menu disabled Download item on pointer hover UI Menu disabled Download item on keyboard focus
UI Select disabled Item 2 on pointer hover UI Select disabled Item 2 on keyboard focus

Use of AI Tools

Implemented and verified with Codex.

@github-actions github-actions Bot added [Package] Components /packages/components [Package] UI /packages/ui labels Nov 1, 2026
@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground

🎉 Props

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: ciampo <mciampini@git.wordpress.org>
Co-authored-by: mirka <0mirka00@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.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

📦 Bundle size

Size Change: +1.62 kB (+0.02%)

Total Size: 8.58 MB

📦 View Changed
Filename Size Change
build/modules/core-fields/post_type_supports.min.js 73.4 kB +13 B (+0.02%)
build/modules/workflow/index.min.js 41.2 kB +187 B (+0.46%)
build/scripts/block-editor/index.min.js 542 kB -16 B (0%)
build/scripts/block-library/index.min.js 415 kB +33 B (+0.01%)
build/scripts/components/index.min.js 336 kB +1.26 kB (+0.38%)
build/scripts/edit-site/index.min.js 376 kB -32 B (-0.01%)
build/scripts/editor/index.min.js 559 kB -33 B (-0.01%)
build/scripts/format-library/index.min.js 79.3 kB +71 B (+0.09%)
build/scripts/media-utils/index.min.js 232 kB -35 B (-0.02%)
build/scripts/widgets/index.min.js 64.2 kB +84 B (+0.13%)
build/styles/components/style-rtl.css 17.5 kB +24 B (+0.14%)
build/styles/components/style-rtl.min.css 14.6 kB +24 B (+0.16%)
build/styles/components/style.css 17.5 kB +21 B (+0.12%)
build/styles/components/style.min.css 14.6 kB +24 B (+0.16%)

c4bc951 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric d462c80 trunk % Change
timeToFirstByte 58.3 ms +3.52% -2.66% 56.45 ms +3.54% -2.3% 3.28%
largestContentfulPaint 96 ms +6.25% -4.17% 92 ms +4.35% -4.35% 4.35%
lcpMinusTtfb 35.65 ms +22.44% -2.52% 33.85 ms +6.2% -2.95% 5.32%
wpBeforeTemplate 30.45 ms +6.47% -4.01% 29.45 ms +7.64% -1.7% 3.4%
wpTemplate 23.51 ms +3.7% -2.51% 22.75 ms +2.33% -2.24% 3.34%
wpTotal 54.36 ms +3.53% -3.11% 52.61 ms +4.05% -2.66% 3.33%
wpMemoryUsage 7.71 MB +0% -0% 7.67 MB +0% -0% 0.43%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric d462c80 trunk % Change
timeToFirstByte 49.05 ms +7.95% -3.16% 45.85 ms +9.38% -0.87% 6.98%
largestContentfulPaint 104 ms +3.85% -1.92% 100 ms +8% -0% 4%
lcpMinusTtfb 54.65 ms +2.65% -2.38% 54.4 ms +1.84% -0.46% 0.46%
wpBeforeTemplate 27.63 ms +12.67% -1.88% 26.36 ms +4.97% -1.78% 4.82%
wpTemplate 17.31 ms +6.53% -3.41% 16.74 ms +6.21% -3.35% 3.41%
wpTotal 45.68 ms +8.73% -3.28% 42.69 ms +10.45% -0.75% 7%
wpMemoryUsage 6.40 MB +0% -0% 6.36 MB +0% -0% 0.53%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric d462c80 trunk % Change
mediaProcessingJpeg 409.25 ms +1.17% -1.38% 406.53 ms +0.86% -0.29% 0.67%
mediaProcessingAvif 6189.69 ms +0.36% -0.24% 6160.27 ms +0.38% -0.02% 0.48%
mediaProcessingJpegToAvif 4286.66 ms +0.16% -0.24% 4255.63 ms +0.3% -0.27% 0.73%

media-upload

Metric d462c80 trunk % Change
jpegUploadProcessing 1952.04 ms +2.1% -24.05% 1454.89 ms +3.44% -0.21% 34.17%
pngUploadProcessing 231.25 ms +25.24% -25.47% 222.96 ms +26.46% -23.99% 3.72%
largeJpegUploadProcessing 1940.47 ms +0.55% -23.92% 1459.27 ms +32.7% -0.62% 32.98%
multipleImageUploadProcessing 2064.85 ms +0.6% -2.05% 2045.8 ms +1.02% -0.45% 0.93%

post-editor

Metric d462c80 trunk % Change
serverResponse 313.71 ms +2.93% -9.94% 317.1 ms +0.47% -9.96% -1.07%
firstPaint 334.97 ms +17.76% -16.97% 303.39 ms +25.84% -10.46% 10.41%
domContentLoaded 655.85 ms +0.57% -0.97% 655.58 ms +1.33% -0.51% 0.04%
loaded 656.52 ms +0.57% -0.96% 656.29 ms +1.33% -0.52% 0.04%
firstContentfulPaint 386.24 ms +4.04% -1.91% 387.27 ms +2.13% -2.1% -0.27%
firstBlock 1683.24 ms +1.36% -0.87% 1677.66 ms +1.25% -0.48% 0.33%
type 14.11 ms +6.59% -6.45% 14.1 ms +4.4% -8.09% 0.07%
typeWithoutInspector 13.7 ms +3.21% -5.99% 14.3 ms +3.43% -5.59% -4.2%
typeWithTopToolbar 18.77 ms +3.09% -5.86% 17.53 ms +7.99% -2.91% 7.07%
typeContainer 6.65 ms +7.37% -4.66% 6.76 ms +5.77% -4.44% -1.63%
focus 90.24 ms +5.52% -5.23% 89.91 ms +2.88% -6.65% 0.37%
firstFocus 194.03 ms +0% -0% 185.41 ms +0% -0% 4.65%
selectAll 305.27 ms +2.35% -0.55% 298.95 ms +4.33% -1.69% 2.11%
undo 24.05 ms +2.04% -3.2% 24.1 ms +3.11% -4.44% -0.21%
listViewOpen 59.97 ms +4.77% -8.14% 57.22 ms +14.56% -5.66% 4.81%
inserterOpen 31.38 ms +8.09% -7.04% 31.57 ms +5.99% -5.48% -0.6%
inserterHover 9.13 ms +8% -6.13% 8.98 ms +5.57% -7.46% 1.67%
inserterSearch 7.12 ms +5.34% -7.58% 7.15 ms +2.38% -3.36% -0.42%
loadPatterns 486.18 ms +4.22% -2.13% 504.93 ms +3.62% -2.59% -3.71%
wpTotal 305.21 ms +2.97% -10.26% 308.57 ms +0.44% -10.28% -1.09%
wpMemoryUsage 14.73 MB +0% -0% 14.72 MB +0% -0% 0.1%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric d462c80 trunk % Change
serverResponse 457.29 ms +0.9% -6.38% 455.57 ms +1.99% -7.76% 0.38%
firstPaint 344.79 ms +7.69% -17.83% 327.36 ms +11.55% -5.88% 5.32%
domContentLoaded 841.81 ms +3.41% -1.53% 837.18 ms +2.21% -0.58% 0.55%
loaded 842.75 ms +3.42% -1.55% 838.09 ms +2.19% -0.57% 0.56%
firstContentfulPaint 487.27 ms +1.84% -3.61% 483.18 ms +3.63% -2.13% 0.85%
firstBlock 2469.95 ms +1.5% -0.77% 2464.93 ms +0.59% -1.55% 0.2%
type 16.62 ms +6.02% -6.62% 16.88 ms +8.06% -4.44% -1.54%
navigate 112.79 ms +4.89% -2.06% 109.5 ms +5.44% -2.25% 3%
loadPatterns 1208.96 ms +9.27% -9.94% 1206.7 ms +5.85% -13.75% 0.19%
loadPages 991.09 ms +0.75% -4.08% 966.68 ms +3.52% -3.73% 2.53%
wpTotal 447.96 ms +0.9% -6.58% 446.05 ms +2.04% -7.9% 0.43%
wpMemoryUsage 12.77 MB +0% -0% 12.73 MB +0% -0% 0.27%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

c4bc951 Run

🏁 Flaky tests

Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

Page List converts to Navigation Links with entity bindings in /test/e2e/specs/editor/blocks/navigation.spec.js, passed after 1 failed attempt.
Error: expect(locator).toContainText(expected) failed

Locator: getByRole('region', { name: 'Editor settings' }).getByRole('tabpanel', { name: 'Content' }).getByRole('button', { name: /Link to:/ })
Expected substring: "test-page-1"
Received string:    "Link to:Cat/catPagePublished"
Timeout: 5000ms

Call log:
  - Expect "toContainText" getByRole('region', { name: 'Editor settings' }).getByRole('tabpanel', { name: 'Content' }).getByRole('button', { name: /Link to:/ }) with timeout 5000ms
  - waiting for getByRole('region', { name: 'Editor settings' }).getByRole('tabpanel', { name: 'Content' }).getByRole('button', { name: /Link to:/ })
    14 × locator resolved to <button type="button" aria-expanded="false" aria-haspopup="dialog" class="components-button link-preview-button is-next-40px-default-size is-secondary">…</button>
       - unexpected value "Link to:Cat/catPagePublished"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/navigation.spec.js:1949:31
Undo restores the post selection when another synced entity is loaded (RTC WebSocket) in /test/e2e/specs/editor/collaboration/collaboration-undo-redo.spec.ts, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 2
+ Received  + 2

  Object {
    "attributeKey": "content",
    "blockIndex": 0,
    "content": "abcdef",
-   "endOffset": 3,
-   "offset": 3,
+   "endOffset": 1,
+   "offset": 1,
  }

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/collaboration-undo-redo.spec.ts:363:5
keeps the inline inserter open when the Block Library panel closes in /test/e2e/specs/editor/various/inserting-blocks.spec.js, passed after 1 failed attempt.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for getByRole('button', { name: 'Add block' })
    - locator resolved to <button type="button" aria-pressed="false" aria-haspopup="true" aria-expanded="false" aria-label="Add block" class="components-button block-editor-inserter__toggle is-next-40px-default-size has-icon">…</button>
  - attempting click action
    - waiting for element to be visible, enabled and stable
    - element is visible, enabled and stable
    - scrolling into view if needed
    - done scrolling
    - element is not visible
  - retrying click action
    - waiting for element to be visible, enabled and stable
  - element was detached from the DOM, retrying

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/inserting-blocks.spec.js:614:59
moves selected text within a paragraph in /test/e2e/specs/editor/various/draggable-blocks.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 1
+ Received  + 1

  Array [
    Object {
      "attributes": Object {
-       "content": "second First third",
+       "content": "First second third",
      },
      "name": "core/paragraph",
    },
  ]

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/draggable-blocks.spec.js:1209:41
should scroll caret into view from the top in /test/e2e/specs/editor/various/typewriter.spec.js, passed after 1 failed attempt.
Error: expect(received).toBeLessThanOrEqual(expected)

Expected: <= 1
Received:    5
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/typewriter.spec.js:277:5
should select by dragging in /test/e2e/specs/editor/various/multi-block-selection.spec.js, passed after 1 failed attempt.
Error: expect(received).toEqual(expected) // deep equality

- Expected  - 1
+ Received  + 0

  Array [
    1,
-   2,
  ]

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/multi-block-selection.spec.js:533:5

c4bc951 Run

@ciampo ciampo self-assigned this Nov 1, 2026
@ciampo ciampo added the [Type] Enhancement A suggestion for improvement. label Nov 1, 2026
@ciampo
ciampo marked this pull request as ready for review November 1, 2026 22:24
@ciampo
ciampo requested a review from a team as a code owner November 1, 2026 22:24
@ciampo ciampo added Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) Backport to WP 7.2 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta and removed Backport to Gutenberg RC Pull request that needs to be backported to a Gutenberg release candidate (RC) labels Nov 2, 2026

@mirka mirka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works very well! I'll go ahead and take over this one to land it through.

mirka added 2 commits November 4, 2026 00:32
…-focus-visible

# Conflicts:
#	packages/components/CHANGELOG.md
#	packages/ui/CHANGELOG.md
Comment thread packages/ui/CHANGELOG.md

### Bug Fixes

- `Menu`, `Select`, and `SelectControl`: Show a focus ring on disabled items when they have keyboard focus ([#85488](https://github.com/WordPress/gutenberg/pull/85488), [#86125](https://github.com/WordPress/gutenberg/pull/86125)).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I merged the changelog entries since they're going in the same version.)

@mirka
mirka enabled auto-merge (squash) November 3, 2026 15:37
@mirka
mirka merged commit f82ac9d into trunk Nov 3, 2026
87 checks passed
@mirka
mirka deleted the codex/disabled-items-focus-visible branch November 3, 2026 15:55
@github-actions github-actions Bot added this to the Gutenberg 24.4 milestone Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

There was a conflict while trying to cherry-pick the commit to the wp/7.2 branch. Please resolve the conflict manually and create a PR to the wp/7.2 branch.

PRs to wp/7.2 are similar to PRs to trunk, but you should base your PR on the wp/7.2 branch instead of trunk.

# Checkout the wp/7.2 branch instead of trunk.
git checkout wp/7.2

# Create a new branch for your PR.
git checkout -b my-branch

# Cherry-pick the commit.
git cherry-pick f82ac9d5d3dd7fe4faa06a583d51daacd17d7015

# Check which files have conflicts.
git status

# Resolve the conflict...
# Add the resolved files to the staging area.
git status
git add .
git cherry-pick --continue

# Push the branch to the repository
git push origin my-branch

# Create a PR and set the base to the wp/7.2 branch.
# See https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-base-branch-of-a-pull-request.

mirka added a commit that referenced this pull request Nov 3, 2026
…ngs (#86269)

* Components, UI: Use focus-visible for disabled item focus rings (#86125)

* Menu: Show disabled-item focus rings only on focus-visible

* Components, UI: Document disabled item focus ring changes

* UI: Write the disabled popup item focus outline directly

---------

Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>

* Link WP 7.2 backport changelog entries

---------

Co-authored-by: Marco Ciampini <marco.ciampo@gmail.com>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
@mirka mirka added Backported to WP Core Pull request that has been successfully merged into WP Core and removed Backport to WP 7.2 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Nov 3, 2026
Vedant-Gandhi pushed a commit to Vedant-Gandhi/gutenberg that referenced this pull request Nov 30, 2026
…Press#86125)

* Menu: Show disabled-item focus rings only on focus-visible

* Components, UI: Document disabled item focus ring changes

* UI: Write the disabled popup item focus outline directly

---------

Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backported to WP Core Pull request that has been successfully merged into WP Core [Package] Components /packages/components [Package] UI /packages/ui [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants