Repository navigation
fix(RadioList): a disabled group's reason describes each radio - #9169
Conversation
With `isDisabled` and a `disabledMessage`, only the radiogroup's `aria-describedby` pointed at the reason tooltip, so a screen reader moving focus onto a radio did not hear why it was disabled: a radio group's description is not reliably announced when focus lands inside it, and `component:RadioList` FR5 requires the reason to describe each focusable radio. Each radio now adds the reason's id to its own `aria-describedby`, after its own description, as CheckboxInput and the other single controls already do; the radiogroup keeps it too (FR1). The tooltip still anchors to and opens from the group. The radio-group binding inventory's disabled-with-message option state now expects the reason as the option's description.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC |
|---|---|---|
| RadioListItem | 55.1 kB (+50 B) · 10.0 kB CSS (0) | — |
| RadioList | 47.2 kB (+34 B) · 8.3 kB CSS (0) | — |
| lab/MobilePowerSearch | 158.2 kB (+24 B) · 1.2 kB CSS (0) | — |
Package size: @astryxdesign/core 6.52 MB packed (+1.0 kB); no new dependencies.
Not run on this PR: add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.
Current run: CI concluded failure; parts of this report may be missing.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
The fix itself is right: in a RadioList disabled with a disabledMessage, each radio now exposes the reason as its accessible description, and the new unit tests and the radio-group binding state fail without the change and pass with it. One change is needed: adding disabledMessageID to the exported RadioListContextValue type makes it new public API (a reachable context member, per architecture:public-component-api INV12) that no current record covers. Please pass the tooltip id through a context that RadioList.tsx declares but RadioList/index.ts does not re-export, and leave RadioListContextValue unchanged, which also makes the PR's "no new public API" checkbox accurate.
[Automated review]
| * description when the radio takes focus, which it does not reliably do for | ||
| * a description on the radiogroup. | ||
| */ | ||
| disabledMessageID?: string; |
There was a problem hiding this comment.
This member makes the reason id part of the exported RadioListContextValue (re-exported from @astryxdesign/core and @astryxdesign/core/RadioList), so it becomes public API under architecture:public-component-api INV12, and no current record admits it. A private, layer-scoped context keeps the fix and leaves the public type unchanged:
// RadioList.tsx: not named in RadioList/index.ts
export const RadioListReasonContext = createContext<string | undefined>(undefined);
<RadioListContext value={contextValue}>
<RadioListReasonContext
value={showsDisabledMessage ? disabledMessageTooltip.describedBy : undefined}>
{children}
</RadioListReasonContext>
</RadioListContext>
// RadioListItem.tsx
const reasonID = use(RadioListReasonContext);
aria-describedby={joinAriaIDs(hasDescription ? descriptionID : null, reasonID)}…tap opens it without selecting
There was a problem hiding this comment.
The fix itself is right: in a RadioList disabled with a disabledMessage, each radio now exposes the reason as its accessible description, and the new tests and the radio-group binding state fail without the change and pass with it. Two changes are needed before it can land:
disabledMessageIDon the exportedRadioListContextValuemakes the reason id public API (a reachable context member underarchitecture:public-component-apiINV12) that no current record covers; pass the tooltip id through a context thatRadioList/index.tsdoes not re-export, and leaveRadioListContextValueunchanged.- Build the radio's
aria-describedbywith the sharedjoinAriaIDshelper fromutils/inputAria.tsinstead of a hand-written filter-and-join, so ARIA id joining keeps one implementation.
[Automated review]
| aria-describedby={ | ||
| [hasDescription ? descriptionID : null, context.disabledMessageID] | ||
| .filter(Boolean) | ||
| .join(' ') || undefined | ||
| } |
There was a problem hiding this comment.
This hand-written join duplicates joinAriaIDs (utils/inputAria.ts), the shared ARIA id joiner that RadioList.tsx already imports. Calling it keeps one implementation of id joining, and fits the same edit that moves the reason id off the public context (reasonID being the id read from that private context):
aria-describedby={joinAriaIDs(hasDescription ? descriptionID : null, reasonID)}… and join with joinAriaIDs
There was a problem hiding this comment.
This fix is ready: in a RadioList disabled with a disabledMessage, every radio now exposes the reason as its accessible description after its own description, and the new unit tests and the radio-group binding state fail without the change and pass with it, in jsdom and in Chromium's accessibility tree. Both earlier requested changes are addressed: the reason id now travels on a private context, leaving RadioListContextValue unchanged, and the radio's ids are joined with joinAriaIDs. As a follow-up, the RadioList record's FR5 implementation-gap note can be removed once this lands.
[Automated review]
There was a problem hiding this comment.
This fix is ready to merge: in a RadioList disabled with a disabledMessage, every radio now exposes the reason as its accessible description after its own description, and the new tests and the radio-group binding state fail without the change and pass with it, in jsdom and in Chromium's accessibility tree. No public API changes, since the reason id travels on a context that the package does not export. As a follow-up, the RadioList record's FR5 implementation-gap note can be removed once this lands.
[Automated review]
Conflicts: RadioListItem keeps aria-disabled, the form detach and the disabled radio's dropped required, and takes main's reason context and status-following aria-invalid; RadioList nests the form and reason contexts. Records keep this branch's FR4/FR5 rows, take main's FR6 aria-invalid clause and RTL verification row, and drop the group-reason gap #9169 closed.
User impact
When a RadioList is disabled with a
disabledMessage, a screen-reader user who moves focus onto one of its radios hears the option and that it is unavailable, but not why. The reason is attached to the radio group, and a group's description is not reliably announced when focus lands inside it.Problem and solution fit
aria-describedbypoints at the reason tooltip; no radio carries it.Each radio now adds the reason's id to its own
aria-describedby, after its own description, the way CheckboxInput and the other single controls already describe themselves with their reason.Expected behavior and authority
component:RadioListFR5: "the reason MUST describe each focusable radio"; its implementation gap is the one fixed here.spec:AST-085FR5: the disabled state is exposed on the focusable element together with its accessible name and any disabled reason.component:RadioListFR1: the radiogroup is described by the disabled reason too, so the reason is kept on the group per FR1; dropping it there would be an FR1 edit.Smallest restoration
RadioList passes the reason tooltip's id to its radios through context while a reason applies; RadioListItem appends it to the radio's
aria-describedby. No prop, default, record or visual change.Evidence
aria-describedbyand an empty accessible description.Siblings: #8823 also edits RadioListItem's disabled attributes and the binding inventory; the later rebases.
Scope
Testing
Local gates at
39869eeb00, one commit on mainabf156aec8:vitestover RadioList, SegmentedControl and DropdownMenu: 15 files, 473 tests pass. The new tests check that every radio carries the reason after its own description, that the radiogroup still carries it (FR1), and that a group that is not disabled adds nothing; the binding inventory's disabled-with-message option state now expects the reason as the option's description.RadioGroup.a11y.chromium.spec.ts, the same binding inventory in Chromium, against a freshpnpm storybook:build: 28 pass; they pass again with Chromium pinned to two cores and four workers. Against main's build, the option state fails.pnpm test:ui: 681 files, 17,071 tests pass;pnpm test:node: everything passes except twocache.test.mjscases (fix(cli): a crashed run's release install is recognized by the Node it ran on, whatever its name #8520), which fail the same way on main.