Skip to content

fix(RadioList): a disabled group's reason describes each radio - #9169

Merged
cixzhang merged 4 commits into
meta:mainfrom
vjeux:fix/radiolist-disabled-reason
Nov 1, 2026
Merged

cixzhang merged 4 commits into
meta:mainfrom
vjeux:fix/radiolist-disabled-reason

Conversation

@vjeux

@vjeux vjeux commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

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

  • Why is the reason missed? Only the radiogroup's aria-describedby points at the reason tooltip; no radio carries it.
  • Why does that harm the task? The focused radio is what a screen reader announces, so the one sentence that explains the locked choice is skipped.
  • Why does it matter? A user can't tell an unavailable plan from a broken control, or what to do about 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:RadioList FR5: "the reason MUST describe each focusable radio"; its implementation gap is the one fixed here.
  • spec:AST-085 FR5: the disabled state is exposed on the focusable element together with its accessible name and any disabled reason.
  • component:RadioList FR1: 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

  • Reproduction before the change: on main, a radio in a group disabled with a reason has no aria-describedby and an empty accessible description.
  • Result after the change: every radio's accessible description is the reason, after its own description when it has one.
  • Representative unchanged path: a group that is not disabled adds nothing; the radiogroup keeps its description.
  • Regression proof: the new unit tests and the binding inventory's disabled-with-message option state fail on main (the two new unit tests, and the option state in jsdom and in Chromium: "the subject has no aria-describedby relationship") and pass here.

Siblings: #8823 also edits RadioListItem's disabled attributes and the binding inventory; the later rebases.

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

Local gates at 39869eeb00, one commit on main abf156aec8:

  • vitest over 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 fresh pnpm storybook:build: 28 pass; they pass again with Chromium pinned to two cores and four workers. Against main's build, the option state fails.
  • Typecheck; lint; Prettier on the touched files; changesets; pnpm test:ui: 681 files, 17,071 tests pass; pnpm test:node: everything passes except two cache.test.mjs cases (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.

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

vercel Bot commented Oct 31, 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 12:08am UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

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

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

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 9487ebe

Storybook · Sandbox · built from this PR's head

Modified components

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

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

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.

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)}

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

  • disabledMessageID on the exported RadioListContextValue makes the reason id public API (a reachable context member under architecture:public-component-api INV12) that no current record covers; pass the tooltip id through a context that RadioList/index.ts does not re-export, and leave RadioListContextValue unchanged.
  • Build the radio's aria-describedby with the shared joinAriaIDs helper from utils/inputAria.ts instead of a hand-written filter-and-join, so ARIA id joining keeps one implementation.

[Automated review]

Comment on lines +356 to +360
aria-describedby={
[hasDescription ? descriptionID : null, context.disabledMessageID]
.filter(Boolean)
.join(' ') || 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.

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)}

@cixzhang
cixzhang marked this pull request as ready for review October 31, 2026 18:38

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

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]

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

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]

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 1, 2026
@cixzhang cixzhang closed this Nov 1, 2026
@cixzhang cixzhang reopened this Nov 1, 2026
@cixzhang
cixzhang merged commit 701c3b2 into meta:main Nov 1, 2026
124 of 130 checks passed
@vjeux
vjeux deleted the fix/radiolist-disabled-reason branch November 1, 2026 01:58
cixzhang added a commit that referenced this pull request Nov 1, 2026
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.

This branch was successfully deployed

1 active deployment
Preview — 9487ebe7 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 A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) 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.

2 participants