Repository navigation
fix(core): choice controls stay focusable when disabled - #7824
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewModified ComponentsCheckboxInput (@astryxdesign/core) · View in Storybook
FileInput (@astryxdesign/core) · View in Storybook
Slider (@astryxdesign/core) · View in Storybook
Switch (@astryxdesign/core) · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: 3 accessibility violation(s) found — 3 serious. Checkbox pattern - 1 issue(s)
CheckboxList - 1 issue(s)
FileInput - 1 issue(s)
Visual Regression46 of 486 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 26 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
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
RadioListin 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
FileInputshows no focus indicator, because the disabled styles override the:focus-withinborder (FR6). - A disabled
Switchstill calls a caller'sonClick(FR2). - CI's
test-uifails:useTableSelection.test.tsx:200still expectstoBeDisabled().
[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); |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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.
…itch onClick while disabled
There was a problem hiding this comment.
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
FileInputopens 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
CheckboxInputclears the nativeindeterminateflag, 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} |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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).
…checkbox stay inert
There was a problem hiding this comment.
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]
Part of #7817 (RadioList is split out; see Smallest restoration)
User impact
Keyboard and screen-reader users cannot reach a disabled
CheckboxInput,CheckboxListitem,Switch,SliderorFileInputunless the builder also set adisabledMessage. Without a message these controls render the nativedisabledattribute, 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
aria-disabled, change guards, form detachment), but only took it whendisabledMessagewas set; otherwise it fell back to nativedisabled.disabledremoves the control from sequential focus and from focus-based screen-reader navigation, so the control and its state are invisible to those users.spec:AST-085makes 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(authoritycurrent, approved 2026-10-21):disabledon any rendered element;aria-disabled="true"; the enabled focus order is kept.Smallest restoration
CheckboxInput,Switch:aria-disabledand form detachment apply to every disabled state; thedisabledattribute is gone. The existingonChangeguards keep blocking toggles;CheckboxInput's guard also restores the nativeindeterminateflag, which activation clears and React does not restore. A caller'sonClickis skipped while disabled, since nativedisabledused to suppress it.Slider: the thumb keepstabIndex={0}; the hidden form carriers are not rendered while disabled, instead of being natively disabled.FileInput: the trigger keeps its Tab stop witharia-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.CheckboxInputstops asking the shareduseIndicatorFocusRinghook to suppress the ring (the hook is unchanged);FileInput's disabled styles keep the:focus-withinborder; theSliderthumb ring no longer requires!isDisabled;Switchgets a focus-only marker,switchFocusScope, which stays on while disabled.switchScopestill drops off, so hover and press stay off on a disabled switch.RadioList. With nativedisabledgone, the browser's arrow keys would land on an individually disabled radio instead of skipping it, andspec:AST-085leaves 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 usedisabledMessageinstead of a wrappingTooltipstill holds), and the now-unusedhasDisabledMessagefield inCheckboxList's context. Both are follow-ups.Evidence
Real Chrome 156 (headless, 2x DPR). Storybook built from
mainat 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.main: reached by Tabsolid 2pxaria-valuenowunchangedrgb(27, 27, 27)as an enabled FileInput (grayrgb(212, 212, 212)before this round)FileInputreached the hidden file input un-canceled (picker path open) and is now canceled; Space or a click on a disabled indeterminateCheckboxInputused to clear the native mixed state (Chrome then exposed it aschecked: false) and now leaves itmixed, as onmain.main, Tab skipped every disabled control above.main.CheckboxInput,Switch,FileInputandSliderfail onmainand pass here. TheSwitchtest also checks that a caller'sonClickdoes not fire; theFileInputtest checks that a direct click on the hidden input is canceled; a newCheckboxInputtest 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.tsxnow expects the focusable disabled row checkbox.Scope
Testing
pnpm vitest runfor CheckboxInput, CheckboxList, Switch, RadioList, Slider, FileInput and the Table selection plugin: all pass.tsc --noEmitfor core, eslint, prettier.mainversus this head.