Skip to content

Standardize component focus states on :focus-visible - #1141

Open
stephaniehobson wants to merge 1 commit into
mainfrom
v23/focus-visible-components
Open

stephaniehobson wants to merge 1 commit into
mainfrom
v23/focus-visible-components

Conversation

@stephaniehobson

@stephaniehobson stephaniehobson commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Description

  • 29 bare :focus selectors across 12 component partials, converted to :focus-visible.
  • Left the single pre-existing :focus-within in _menu.scss alone.
  • Form text inputs are a separate, deliberately excluded case.
  • I have documented this change in the design system.
  • I have recorded this change in CHANGELOG.md.

Issue

Part of #1084

Testing

npm run lint, npm test (47 specs, Firefox + Chrome), and a direct sass compile all pass.

29 bare :focus selectors across 12 component partials, converted to
:focus-visible so the focus ring only shows for keyboard/assistive-tech
focus rather than every mouse click. Left the single pre-existing
:focus-within in _menu.scss alone -- different pseudo-class, not in
scope.

  Breadcrumb, Button, Card, Footer, Menu, Menu Item, Menu List,
  Modal, Navigation, Notification Bar, Sidebar Menu, Sticky Promo

Mechanical rename -- all 29 occurrences were the simple &:focus {
or &:focus, shape, no ambiguity with other selectors. Verified with
a targeted grep across the 12 files before and after (0 bare :focus
remaining, 29 :focus-visible present) and a direct sass compile.

Form text inputs/textareas are a separate, deliberately excluded case
(D2, not this commit) -- :focus-visible doesn't reliably match
mouse-focused text fields across engines, so losing the ring on click
there would be a real accessibility regression, not an improvement.

Stacked on v23/desc-to-body (branched here per the plan's documented
fallback, since that stack hasn't merged yet -- will rebase onto main
once it does). Part of #1084.

Verified: npm run lint, npm test (47 specs, Firefox + Chrome), and a
direct sass --verbose compile confirming 18 :focus-visible selectors
in the compiled protocol-components.css with no new warnings.
@stephaniehobson
stephaniehobson force-pushed the v23/focus-visible-components branch from 40e037a to e9b1aa0 Compare September 11, 2026 21:42
@stephaniehobson
stephaniehobson changed the base branch from v23/desc-to-body to main September 11, 2026 21:42
@stephaniehobson
stephaniehobson added this pull request to stack #1150 September 11, 2026 21:42
@stephaniehobson
stephaniehobson marked this pull request as ready for review September 12, 2026 04:03
@stephaniehobson
stephaniehobson requested a lite review from Copilot September 12, 2026 04:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Address the documented browser-compatibility and documentation concerns before approval.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Standardizes component focus styling by replacing 29 bare :focus selectors with :focus-visible.

Changes:

  • Updates focus states across 12 component Sass partials.
  • Preserves form-control focus styles and existing :focus-within.
  • Documents the change in CHANGELOG.md.
File summaries
File Summary
CHANGELOG.md Documents the focus-state changes.
assets/sass/protocol/components/_sticky-promo.scss Updates promo focus styling.
assets/sass/protocol/components/_sidebar-menu.scss Updates sidebar focus styling.
assets/sass/protocol/components/_notification-bar.scss Updates notification focus styling.
assets/sass/protocol/components/_navigation.scss Updates navigation focus styling.
assets/sass/protocol/components/_modal.scss Updates modal focus styling.
assets/sass/protocol/components/_menu.scss Updates menu focus styling.
assets/sass/protocol/components/_menu-list.scss Updates menu-list focus styling.
assets/sass/protocol/components/_menu-item.scss Updates menu-item focus styling.
assets/sass/protocol/components/_footer.scss Updates footer focus styling.
assets/sass/protocol/components/_card.scss Updates card focus styling.
assets/sass/protocol/components/_button.scss Updates button focus styling.
assets/sass/protocol/components/_breadcrumb.scss Updates breadcrumb focus styling.
Review details

Suppressed comments (3)

CHANGELOG.md:54

  • The PR checklist says this change is documented in the design system, but this diff only adds a changelog entry and the docs/ tree has no guidance for :focus-visible or the form-input exception. Please add the accessibility guidance to the design-system documentation, or correct the checklist before merging this breaking behavior change.
* (breaking) Standardized interactive component states on `:focus-visible` instead of `:focus`, so the focus ring only shows for keyboard/assistive-tech focus rather than every mouse click. Affects Breadcrumb, Button, Card, Footer, Menu, Menu Item, Menu List, Modal, Navigation, Notification Bar, Sidebar Menu, and Sticky Promo. Text inputs keep `:focus` -- see the next entry.

assets/sass/protocol/components/_card.scss:105

  • This selector is shipped while package.json:60-63 still declares defaults plus IE 8. IE 8 does not recognize :focus-visible; in grouped rules like this one, the invalid pseudo-class can discard the entire hover/active rule, and the standalone focus rule gives no custom focus state. Either update the supported-browser target as part of this breaking release or retain a fallback for browsers without :focus-visible.
        &:focus-visible {

assets/sass/protocol/components/_navigation.scss:203

  • Putting :focus-visible in this comma-separated selector list makes the entire rule invalid in browsers that do not recognize that pseudo-class; those browsers then lose the existing hover/active background as well as the focus state. This pattern is repeated throughout the changed component partials, and the release browser baseline is not defined yet. Split the hover/active selectors from the :focus-visible rule (or explicitly gate the new selector with a supported-browser baseline) in every occurrence.
    &:focus-visible,
  • Files reviewed: 13/13 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread CHANGELOG.md

### Accessibility

* (breaking) Standardized interactive component states on `:focus-visible` instead of `:focus`, so the focus ring only shows for keyboard/assistive-tech focus rather than every mouse click. Affects Breadcrumb, Button, Card, Footer, Menu, Menu Item, Menu List, Modal, Navigation, Notification Bar, Sidebar Menu, and Sticky Promo. Text inputs keep `:focus` -- see the next entry.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will be addressed in next PR in stack.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants