Tabs: Fix missing keyboard focus ring on the panel in Windows High Contrast mode when rendered inside wp-admin#77469
Conversation
The Panel component renders a div that relies on a transparent outline
for forced-colors (Windows high contrast) focus visibility. wp-admin's
common.css unlayered `div { outline: 0 }` beat the layered declaration,
erasing the focus indicator in high contrast mode. Apply
`defenseStyles.div` so the unlayered class-scoped bridge preserves it.
|
Size Change: 0 B Total Size: 7.75 MB ℹ️ View Unchanged
|
Replace the hand-rolled box-shadow / transparent-outline focus indicator
on Tabs.Panel with the shared `outset-ring--focus-visible` utility from
`focus.module.css`. Aligning with the utility gives the panel a
consistent focus treatment across the package, and the utility already
drives `--_gcd-div-outline`, so the panel now survives wp-admin's
unlayered `div { outline: 0 }` via the global-css-defense bridge
(`defenseStyles.div` is kept for that reason).
|
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 If 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. |
mirka
left a comment
There was a problem hiding this comment.
Works as expected 👍 Thanks for the clean up!
|
Thanks for the review! The CI is failing, but it's unrelated to this PR, so I will merge it. See #77472 |
|
Flaky tests detected in cf5bae8. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/24667040577
|
…ntrast mode when rendered inside wp-admin (#77469) * Tabs: Defend panel outline against wp-admin div reset The Panel component renders a div that relies on a transparent outline for forced-colors (Windows high contrast) focus visibility. wp-admin's common.css unlayered `div { outline: 0 }` beat the layered declaration, erasing the focus indicator in high contrast mode. Apply `defenseStyles.div` so the unlayered class-scoped bridge preserves it. * Tabs: Use shared focus-ring utility on the panel Replace the hand-rolled box-shadow / transparent-outline focus indicator on Tabs.Panel with the shared `outset-ring--focus-visible` utility from `focus.module.css`. Aligning with the utility gives the panel a consistent focus treatment across the package, and the utility already drives `--_gcd-div-outline`, so the panel now survives wp-admin's unlayered `div { outline: 0 }` via the global-css-defense bridge (`defenseStyles.div` is kept for that reason). * Tabs: Add CHANGELOG entry for panel focus ring fix Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org>

What?
Add defensive styling to the
Tabs.Panelcomponent so that its focus indicator remains visible under Windows high contrast /forced-colorsmode when the component is rendered inside wp-admin.Why?
The WordPress core applies
outline: noneto thedivelement, so the focus ring is not displayed.How?
Unlike issue #77467, this problem cannot be solved by simply introducing a defensive style because
--_gcd-div-outlineis undefined. To make this defensive style work, this PR introduces a focus utility to this component and draws the focus ring with an outline instead of box-shadow.Testing Instructions
Renderingpanel → setEmulate CSS media feature forced-colorstoactive.Screenshots or screencast
Before
After
Use of AI Tools
Authored with assistance from Claude Code; reviewed and validated by the author.