Repository navigation
Components, UI: Use focus-visible for disabled item focus rings - #86125
Conversation
🤖 PR meta 🤖🎉 PropsIf 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. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: +1.62 kB (+0.02%) Total Size: 8.58 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome 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
|
mirka
left a comment
There was a problem hiding this comment.
Works very well! I'll go ahead and take over this one to land it through.
…-focus-visible # Conflicts: # packages/components/CHANGELOG.md # 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)). |
There was a problem hiding this comment.
(I merged the changelog entries since they're going in the same version.)
|
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. |
…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>
…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>
Follow-up to the disabled-item focus discussion in #85488.
What?
Show disabled-item focus rings only when
:focus-visiblematches in both Menu implementations, legacyMenuItem/DropdownMenu, and UISelect/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-visiblewith 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-visibleand show a ring.Other components investigated
:focus-visiblerule does not replace its highlight.aria-activedescendant. Replacing the selected-option ring with:focus-visiblewould remove the keyboard cue.:focus-visibleordata-focus-visible.No input-modality tracking or interaction changes are added.
Testing Instructions
isDisabledproperty totruein Storybook Controls, then hover it. It should have no ring.Testing Instructions for Keyboard
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.
Use of AI Tools
Implemented and verified with Codex.