Skip to content

fix(Field): a focused field shows its focus under forced colors - #9392

Merged
cixzhang merged 2 commits into
mainfrom
fix/field-focus-forced-colors
Nov 2, 2026
Merged

cixzhang merged 2 commits into
mainfrom
fix/field-focus-forced-colors

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

User impact

People who use forced colors (Windows High Contrast, and some low-vision setups) couldn't see which field had keyboard focus. A focused TextInput, TextArea, NumberInput, Selector, MultiSelector, Typeahead, Tokenizer, or date or time input looked exactly like one at rest, with or without a status. Now a focused field's border turns the system Highlight color. Nothing changes outside forced colors.

Not in this PR: disabled fields stay focusable (AST-085), but their own focus styles (the shared disabled focus ring, and Selector's, MultiSelector's, DateInput's and TimeInput's) have no forced-colors branch yet. That's tracked as a separate fix.

Problem and solution fit

  • Cause: the field-focus treatment is an accent border plus an inset box-shadow. Forced colors drop every box shadow and repaint author border colors in one system color, so both parts vanished there.
  • Fix: under @media (forced-colors: active), a focused field's border is Highlight. System colors survive forced colors, so this is the one edge change that shows.
    • It sits in three places in the shared input styles: the base wrapper, the status focus styles, and the status border styles.
    • The last covers Selector and MultiSelector, which apply only the status border.
  • Why not an outline: the shared focus-outline module owns every outline ring, and the repository's lint rules enforce that. A border color change stays within field styling and needs no new ring.

Current specification

spec:AST-020 FR1 makes WCAG 2.2 AA the baseline, and 2.4.7 (Focus Visible) applies under forced colors as under any other colors. Specs & Decisions ruled this a defect decided by FR1. No record changes.

Evidence

Real Chrome 156 with forced-colors emulation, against Storybook built from this head and from main (a7d0b3f). FieldForcedColorsFocus.a11y.chromium.spec.ts tabs to each field and checks that the field's edge changes:

Case main This PR
TextInput, no status fails (edge unchanged) passes
TextInput, error status fails passes
Selector, error status fails passes
  • The TextInput, Selector and Field Chromium specs pass, except three that fail identically on main's build in this offline rig: the Field label audit needs a git checkout, and Selector combobox "open" and "busy" fail on main too.
  • Field, TextInput and Selector unit suites: 587 passed. check:changesets: clean.

LOC

+142 / −9: about 40 style lines, most of them the three status types, and a 95-line Chromium spec.

Scope

  • One change: a focused field shows focus under forced colors.
  • No record change.
  • Public text contains no internal context.

Forced colors (Windows High Contrast) drop box shadows and repaint author
border colors in one system color, so the field-focus treatment (an accent
border and an inset shadow) vanished there and a focused field looked the
same as one at rest, against WCAG 2.4.7 (AST-020 FR1).

Under forced colors, a focused field's border now takes the system Highlight
color, in the base wrapper style and in the status border and status focus
styles, so Selector and MultiSelector, which apply only the status border,
get it too. Nothing changes outside forced colors. A Chromium spec with
forced-colors emulation covers TextInput with and without a status and a
Selector with a status.
@vercel

vercel Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 1, 2026 11:55pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 1, 2026
@astracat-bot

astracat-bot Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 2, 2026, 12:05 AM UTC

@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Nov 1, 2026
@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · ec3a32a

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
Field 46.5 kB (0) · 8.3 kB CSS (0) — ✗ · ✓ · —
FieldLabel 40.2 kB (0) · 5.9 kB CSS (0) — ✗ · ✓ · —
MultiSelector 76.7 kB (+30 B) · 15.1 kB CSS (+24 B) — — · — · —
28 more components
Component Size LoC Visual · A11y · RTL
Selector 80.9 kB (+28 B) · 15.5 kB CSS (+19 B) — — · — · —
Tokenizer 73.6 kB (+10 B) · 17.0 kB CSS (+32 B) — — · — · —
Pagination 89.5 kB (+13 B) · 15.8 kB CSS (+21 B) — — · — · —
lab/TransferListSelector 76.4 kB (+30 B) · 1.9 kB CSS (0) — — · — · —
ComplexSelector 59.7 kB (+4 B) · 11.1 kB CSS (+23 B) — — · — · —
TextArea 51.8 kB (+2 B) · 9.8 kB CSS (+23 B) — — · — · —
PowerSearch 176.3 kB (+5 B) · 20.4 kB CSS (+19 B) — — · — · —
DateInput 103.9 kB (+6 B) · 15.2 kB CSS (+16 B) — — · — · —
DateTimeInput 115.7 kB (0) · 15.6 kB CSS (+21 B) — — · — · —
TextInput 56.9 kB (+2 B) · 10.9 kB CSS (+19 B) — — · — · —
TimeInput 92.4 kB (+3 B) · 14.1 kB CSS (+17 B) — — · — · —
NumberInput 59.2 kB (+2 B) · 11.1 kB CSS (+17 B) — — · — · —
Typeahead 66.5 kB (+4 B) · 11.7 kB CSS (+14 B) — — · — · —
DateRangeInput 73.2 kB (+5 B) · 11.6 kB CSS (+12 B) — — · — · —
lab/CommentComposer 98.0 kB (+12 B) · 1.9 kB CSS (0) — — · — · —
lab/MobilePowerSearch 161.0 kB (+11 B) · 1.2 kB CSS (0) — — · — · —
lab/ChatReactionBar 69.3 kB (+10 B) · 1.1 kB CSS (0) — — · — · —
lab/TransferList 70.7 kB (+9 B) · 1.7 kB CSS (0) — — · — · —
richtext/RichTextEditorToolbar 217.4 kB (+9 B) · 454 B CSS (0) — — · — · —
lab/ChatEmojiPicker 68.8 kB (+8 B) · 773 B CSS (0) — — · — · —
lab/MobileTokenizer 96.6 kB (+8 B) · 880 B CSS (0) — — · — · —
lab/EmojiPicker 66.6 kB (+7 B) · 722 B CSS (0) — — · — · —
lab/Comments 226.7 kB (+6 B) · 2.5 kB CSS (0) — — · — · —
richtext/RichTextEditor 273.3 kB (+6 B) · 2.6 kB CSS (0) — — · — · —
lab/CommentThread 222.1 kB (+3 B) · 2.4 kB CSS (0) — — · — · —
InputGroup 47.1 kB (+2 B) · 8.4 kB CSS (0) — — · — · —
FileInput 57.7 kB (0) · 10.7 kB CSS (0) — — · — · —
lab/ListInput 78.6 kB (0) · 1.6 kB CSS (0) — — · — · —
Visual changes: 2 snapshots in 1 component

A change is a question for the reviewer, not a failure.

Component · story Before After Diff
Field · Default (neutral, light) before frame after frame diff frame
Field · Default (neutral, dark) before frame after frame diff frame

Package size: @astryxdesign/core 5.69 MB packed (+353 B); no new dependencies.

API changes: core +0 · ~3 · −0

Committed API report behind this build: core 4 rows; run pnpm api:report.

3 API changes (advisory)
Package Where Signature Usage
~ core . · Values · const inputStatusBorderStyles const inputStatusBorderStyles: Readonly<{ readonly warning: Readonly<{ readonly borderColor: stylex.StyleXClassNameFor<"borderColor", "var(--color-text-warning)"> }>; readonly error: Readonly … #a9ac1cbc → const inputStatusBorderStyles: Readonly<{ readonly warning: Readonly<{ readonly borderColor: stylex.StyleXClassNameFor<"borderColor", "var(--color-text-warning)" | "Highlight"> }>; readonly e … #739ff723 import {inputStatusBorderStyles} from '@astryxdesign/core'
~ core . · Values · const inputStatusFocusWithinStyles const inputStatusFocusWithinStyles: Readonly<{ readonly warning: Readonly<{ readonly borderColor: stylex.StyleXClassNameFor<"borderColor", "var(--color-text-warning)"> }>; readonly error: Readonly … #a9ac1cbc → const inputStatusFocusWithinStyles: Readonly<{ readonly warning: Readonly<{ readonly borderColor: stylex.StyleXClassNameFor<"borderColor", "var(--color-text-warning)" | "Highlight"> }>; readonly e … #739ff723 import {inputStatusFocusWithinStyles} from '@astryxdesign/core'
~ core . · Values · const inputWrapperStyles const inputWrapperStyles: Readonly<{ readonly base: Readonly<{ readonly boxSizing: stylex.StyleXClassNameFor<"boxSizing", "border-box">; readonly position: stylex.StyleXClassNameFor<"pos … #2e7e1cc8 → const inputWrapperStyles: Readonly<{ readonly base: Readonly<{ readonly boxSizing: stylex.StyleXClassNameFor<"boxSizing", "border-box">; readonly position: stylex.StyleXClassNameFor<"pos … #90a96087 import {inputWrapperStyles} from '@astryxdesign/core'

Touched components checked; add ci:run-visual or ci:run-rtl to run the full suites.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The forced-colors focus fix works for enabled fields in Chromium, but approval waits on an engineering owner decision and one wording fix. No current spec record chooses a 1px Highlight border as the forced-colors focus treatment for Field inputs (spec:AST-020 FR1, WCAG 2.4.7, only requires a visible indicator), and none decides the resulting type changes to the exported inputWrapperStyles, inputStatusBorderStyles and inputStatusFocusWithinStyles. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, or names the record that should state the treatment, and the author may do so if they are an engineering owner. Separately, disabled fields stay focusable and must show keyboard focus (spec:AST-085 FR6) but still show none under forced colors, so either add the Highlight branch to the disabled focus rings (inputDisabledFocus.ts and the Selector, MultiSelector, DateInput and TimeInput disabled styles) or narrow the changeset to enabled fields.

[Automated review]

Comment thread .changeset/field-focus-forced-colors.md Outdated
'@astryxdesign/core': patch
---

[fix] Field inputs (TextInput, TextArea, NumberInput, Selector, MultiSelector, Typeahead, Tokenizer, and the date and time inputs) now show keyboard focus under forced colors, such as Windows High Contrast. Forced colors drop the inset focus shadow and repaint every border in one system color, so a focused field looked the same as one at rest. A focused field's border now takes the system Highlight color there, with or without a status. Nothing changes outside forced colors.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Disabled fields stay focusable and must show keyboard focus (spec:AST-085 FR6), but under forced colors they still show none: inputDisabledFocusStyles.ring/.nestedRing and the Selector, MultiSelector, DateInput and TimeInput disabled focus styles replace the base border without the Highlight branch. Either add the branch there, or narrow this note to enabled fields.

@cixzhang cixzhang added the ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) label Nov 1, 2026
@cixzhang
cixzhang marked this pull request as ready for review November 1, 2026 23:40
CodeBunny on #9392: focusable disabled fields keep their own focus styles,
which have no forced-colors branch yet, so the note now says enabled fields.
@cixzhang

cixzhang commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec ec3a32a

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The forced-colors focus fix is ready: enabled Field inputs now show a Highlight border at keyboard focus in High Contrast, and an engineering owner confirmed that treatment on this head. One optional follow-up: a Selector or MultiSelector with a status now also shows that border after a mouse pick, while one without a status does not, because the status border style is applied after the pointer-restored focus suppression. A status-keyed suppression applied after the status border, plus a mouse-pick case in the Chromium spec, would keep the two consistent.

[Automated review]

* Keyed by InputStatusType.
* Keyed by InputStatusType. Under forced colors a focused field's border is
* Highlight, as in the base style, for wrappers that apply no status focus
* style of their own (Selector, MultiSelector).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For Selector and MultiSelector this branch also replaces selectorPresentationStyles.pointerRestoredFocus, which they apply earlier in the same style list, so under forced colors a status trigger shows Highlight after a mouse pick while a trigger without a status does not. A status-keyed suppression applied after the status border when the focus ring is suppressed would keep them consistent.

@cixzhang
cixzhang merged commit 789197b into main Nov 2, 2026
95 of 98 checks passed
@github-actions
github-actions Bot deleted the fix/field-focus-forced-colors branch November 2, 2026 06:05

This branch was successfully deployed

1 active deployment
Preview — ec3a32ac Deployed Nov 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) CLA Signed This label is managed by the Meta Open Source bot. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant