Skip to content

fix(core): choice controls stay focusable when disabled - #7824

Merged
cixzhang merged 4 commits into
mainfrom
fix/choice-controls-focusable-disabled
Oct 21, 2026
Merged

cixzhang merged 4 commits into
mainfrom
fix/choice-controls-focusable-disabled

Conversation

@cixzhang

@cixzhang cixzhang commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Part of #7817 (RadioList is split out; see Smallest restoration)

User impact

Keyboard and screen-reader users cannot reach a disabled CheckboxInput, CheckboxList item, Switch, Slider or FileInput unless the builder also set a disabledMessage. Without a message these controls render the native disabled attribute, so Tab skips them and a screen reader moving by focus never hears that the option exists or that it is unavailable. In a settings form with a few locked options, a keyboard user sees a shorter form than everyone else and cannot find out what is locked.

After this change every disabled control in this set keeps its Tab stop, is announced as disabled, and still cannot be changed or submitted.

Problem and solution fit

  • Why does it happen? Each component already had a focusable-disabled path (aria-disabled, change guards, form detachment), but only took it when disabledMessage was set; otherwise it fell back to native disabled.
  • Why does it hurt? Native disabled removes the control from sequential focus and from focus-based screen-reader navigation, so the control and its state are invisible to those users.
  • Why does it matter? spec:AST-085 makes focusable disabled the rule for every Astryx control: users must be able to find a disabled control and hear that it is disabled.

Fix: take the existing focusable-disabled path for every isDisabled, not only when a reason is set.

Expected behavior and authority

spec:AST-085 (authority current, approved 2026-10-21):

  • FR1: no native disabled on any rendered element; aria-disabled="true"; the enabled focus order is kept.
  • FR2: a disabled control must not change its value, activate, or invoke a callback, by pointer, keyboard, drag or any other path.
  • FR3: a disabled field contributes no value to form submission and does not block submission through constraint validation.
  • FR6: the keyboard focus indicator still appears on a focused disabled control.

Smallest restoration

  • CheckboxInput, Switch: aria-disabled and form detachment apply to every disabled state; the disabled attribute is gone. The existing onChange guards keep blocking toggles; CheckboxInput's guard also restores the native indeterminate flag, which activation clears and React does not restore. A caller's onClick is skipped while disabled, since native disabled used to suppress it.
  • Slider: the thumb keeps tabIndex={0}; the hidden form carriers are not rendered while disabled, instead of being natively disabled.
  • FileInput: the trigger keeps its Tab stop with aria-disabled; the hidden file input is detached from the form instead of natively disabled, and a direct click on it (from the label or description) is canceled while disabled. The existing guards keep the trigger from opening the picker.
  • Focus indicator (FR6): CheckboxInput stops asking the shared useIndicatorFocusRing hook to suppress the ring (the hook is unchanged); FileInput's disabled styles keep the :focus-within border; the Slider thumb ring no longer requires !isDisabled; Switch gets a focus-only marker, switchFocusScope, which stays on while disabled. switchScope still drops off, so hover and press stay off on a disabled switch.
  • No API, prop, default, or visual change. Disabled paint is unchanged.
  • Not in this PR: RadioList. With native disabled gone, the browser's arrow keys would land on an individually disabled radio instead of skipping it, and spec:AST-085 leaves which items a roving group's arrow keys visit to RadioList's own record, which does not exist yet. That decision goes to the specifications track first. Also not here: consumer docs whose rationale says disabled controls "swallow hover events" (the advice to use disabledMessage instead of a wrapping Tooltip still holds), and the now-unused hasDisabledMessage field in CheckboxList's context. Both are follow-ups.

Evidence

Real Chrome 156 (headless, 2x DPR). Storybook built from main at 7b66913 and from this PR at 4492980 (table) and 29958e3 (the two rows below the table), served locally; the same probe ran each disabled story: Tab from the page start, then Space, ArrowRight, Enter and a mouse click on the disabled control, then Chrome's accessibility node for it.

Disabled story main: reached by Tab PR: reached by Tab PR: value after Space / arrows / Enter / click PR: accessibility node PR: keyboard focus indicator
CheckboxInput no yes unchanged checkbox, disabled, focusable ring
CheckboxList (group) no (0 stops) yes (3 stops) unchanged checkbox, disabled, focusable ring
Switch no yes unchanged switch, disabled, focusable track outline solid 2px
Slider no yes aria-valuenow unchanged slider, disabled, focusable ring
FileInput no yes picker not opened button, disabled, focusable accent border, the same rgb(27, 27, 27) as an enabled FileInput (gray rgb(212, 212, 212) before this round)
  • Also on this head (29958e3), against the previous head 4492980: clicking the label of a disabled FileInput reached the hidden file input un-canceled (picker path open) and is now canceled; Space or a click on a disabled indeterminate CheckboxInput used to clear the native mixed state (Chrome then exposed it as checked: false) and now leaves it mixed, as on main.
  • Reproduction before the change: on main, Tab skipped every disabled control above.
  • Result after the change: each control is reached by Tab, Chrome reports it as disabled and focusable, every change attempt leaves its value unchanged, and the focus indicator paints, dimmed by the existing disabled paint as on the rest of the control.
  • Representative unchanged path: the enabled FileInput's focused border and the enabled Switch ring match main.
  • Regression tests: the new disabled-without-a-reason tests in CheckboxInput, Switch, FileInput and Slider fail on main and pass here. The Switch test also checks that a caller's onClick does not fire; the FileInput test checks that a direct click on the hidden input is canceled; a new CheckboxInput test keeps a disabled indeterminate checkbox mixed after Space and a click (both fail without their fix). The a11y contract facts for the disabled checkbox, list item and switch now record a Tab stop. useTableSelection.test.tsx now expects the focusable disabled row checkbox.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm vitest run for CheckboxInput, CheckboxList, Switch, RadioList, Slider, FileInput and the Table selection plugin: all pass.
  • tsc --noEmit for core, eslint, prettier.
  • Real Chrome 156 probe of the five disabled stories above, main versus this head.

@vercel

vercel Bot commented Oct 21, 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 Oct 21, 2026 8:29pm UTC

Request Review

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

astracat-bot Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 21, 2026, 9:12 PM UTC

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

Modified Components

CheckboxInput (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 351 -
Complexity N/A Very High (39) -
FileInput (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 713 -
Complexity N/A Very High (105) -
Slider (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 951 -
Complexity N/A Very High (145) -
Switch (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 561 -
Complexity N/A Very High (49) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.9KB 1.2KB

Accessibility Audit

Status: 3 accessibility violation(s) found — 3 serious.

Checkbox pattern - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/25 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
CheckboxList - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 3/19 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
FileInput - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 3/15 stories · Learn more
    • WCAG: 1.4.3 (Level AA)

Visual Regression

46 of 486 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 753,933
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,072
Chat Full AI Chat probe light 230,823
Chat Full AI Chat probe dark 229,805
RichTextEditor Markdown parity: side by side probe dark 94,866
RichTextEditor Markdown parity: side by side probe light 89,762
Collapsible Dividers probe dark 66,445
Collapsible Dividers probe light 66,445
Chat Default neutral dark 36,304
Chat Default neutral light 35,767
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,406
Chat With Attachments probe dark 11,232
ProgressBar With Target Mark probe dark 7,895
ProgressBar With Target Mark probe light 7,895
Markdown Default neutral dark 7,573
Markdown Default neutral light 7,566

and 26 more.


Generated by PR Enrichment workflow | Storybook | Sandbox | 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.

Thanks — on this head every disabled control in the set is reached by Tab and exposed as disabled, and its value stays unchanged, as spec:AST-085 asks. Approval waits on a maintainer deciding whether RadioList arrow keys should now land on individually disabled options (they used to skip them), because AST-085 leaves that choice to RadioList's own record and none exists yet. These fixes are needed either way:

  • A required RadioList in a <form> whose selected option is disabled can no longer be submitted: form="" moves the checked radio out of its native group, so the other radios report a missing value and add a Tab stop (AST-085 FR3, FR1).
  • A focused disabled FileInput shows no focus indicator, because the disabled styles override the :focus-within border (FR6).
  • A disabled Switch still calls a caller's onClick (FR2).
  • CI's test-ui fails: useTableSelection.test.tsx:200 still expects toBeDisabled().

[Automated review]

const isChecked = context.value === value;
// Leave the form only when this radio could submit or the whole group is
// disabled: detaching one radio splits the native group (an extra Tab stop).
const detachesFromForm = isDisabled && (context.isDisabled || isChecked);

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.

Inside a <form>, form="" on the checked disabled radio gives it a null form owner, so it leaves its native radio group (name plus form owner). The remaining radios then form a group with nothing checked: with required (line 309) the form can no longer be submitted (checkValidity() is false in Chromium, while main submits), and Tab stops on both the first option and the checked one. A required group whose options are all individually disabled is blocked too, since none of them detaches. AST-085 FR3: a disabled field "does not block submission through constraint validation".

tabIndex={isDisabled && !showsDisabledMessage ? -1 : 0}
aria-disabled={showsDisabledMessage ? 'true' : undefined}
// A disabled trigger keeps its Tab stop (spec:AST-085 FR1).
tabIndex={0}

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 trigger is now a Tab stop while disabled, but dropzoneDisabled and compactDisabled (lines 179–183 and 221–225) pin borderColor, which overrides the :focus-within accent that is FileInput's only focus feedback. In Chromium the focused disabled FileInput is pixel-identical to the unfocused one. AST-085 FR6 needs the focus indicator under keyboard modality; keeping ':focus-within': colorVars['--color-accent'] in both disabled styles would restore it.

aria-disabled={showsDisabledMessage ? 'true' : undefined}
form={showsDisabledMessage ? '' : undefined}
// Focusable but detached from the form while disabled (spec:AST-085).
aria-disabled={isDisabled ? 'true' : undefined}

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.

With native disabled gone, a click on the disabled switch now bubbles to the field wrapper, which receives ...rest and so the caller's onClick (line 746). A user-event click calls it once here and never on main. AST-085 FR2: a disabled control must not invoke a callback; CheckboxInput withholds onClick while disabled, and Switch needs the same.

@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.

Thanks — on this head every disabled control in the set is reached by Tab, exposed as disabled and kept out of form submission, as spec:AST-085 asks, and the earlier FileInput focus, Switch onClick and Table test findings are fixed. Two change paths still get through and need fixing before approval:

  • Clicking the label or description of a disabled FileInput opens the file picker, because the hidden file input is no longer natively disabled; cancelling its click while disabled, with a test, would close both paths (FR2).
  • Space or a click on a disabled indeterminate CheckboxInput clears the native indeterminate flag, so it is exposed as not checked while it still shows the mixed dash; restoring the flag in the disabled guard would fix it (FR2).

[Automated review]

disabled={isDisabled}
// Detached from its form while disabled, so selected files are not
// submitted and `required` does not block submission (FR3).
form={isDisabled ? '' : undefined}

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.

With native disabled gone, this hidden input is still the target of the Field label (inputID={id} at line 816 becomes the label's htmlFor) and of the description's click forwarding, so clicking either on a disabled FileInput opens the file picker; in Chromium the head fires the file chooser for both clicks and the base fires neither. AST-085 FR2 says a disabled control must not activate or open a surface. Cancelling this input's click while disabled (an onClick that calls preventDefault() when isDisabled) would close both paths, and a test that clicks the label and the description would keep them closed.

form={isDisabled ? '' : undefined}
// Native `disabled` suppressed onClick (FR2); preventDefault here
// would desync React's controlled checked state.
onClick={isDisabled ? undefined : rest.onClick}

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.

Space or a click on a focused disabled indeterminate checkbox still runs the native toggle, which clears indeterminate; the onChange guard below returns and React restores only checked, so Chrome's accessibility tree goes from mixed to not checked while the indicator keeps the dash. Setting e.currentTarget.indeterminate = isIndeterminate in the guard's early return (line 476) would keep the mixed state (AST-085 FR2).

@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.

Thanks — on this head every disabled CheckboxInput, CheckboxList item, Switch, Slider and FileInput is reached by Tab, announced as disabled, kept from changing and kept out of form submission, as spec:AST-085 asks, and the FileInput label and mixed-checkbox gaps from the last round are closed with tests. Nothing blocks approval. One optional follow-up, which the description already plans: the disabledMessage docs for these components still say disabled controls swallow the hover events a wrapping Tooltip needs, which stops being true once they are no longer natively disabled.

[Automated review]

@cixzhang
cixzhang merged commit 4b0b8f6 into main Oct 21, 2026
58 checks passed
@github-actions
github-actions Bot deleted the fix/choice-controls-focusable-disabled branch October 22, 2026 06:22

This branch was successfully deployed

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

Labels

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