Skip to content

fix(Selector): keep a caller aria-labelledby on the trigger - #8710

Merged
cixzhang merged 1 commit into
meta:mainfrom
kyu-rong:fix/selector-caller-labelledby
Oct 27, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
kyu-rong:fix/selector-caller-labelledby

Conversation

@kyu-rong

@kyu-rong kyu-rong commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

User impact

A builder who names a Selector by a nearby heading, for example <Selector label="Fruit" aria-labelledby="lunch-heading" /> under a "Lunch" heading, loses that name. Screen-reader users hear only "Fruit", so two Fruit pickers in different sections of the same form sound identical.

Problem and solution fit

  • Why does it happen? Selector builds the trigger's props from the caller's props and then writes its own aria-labelledby. Standalone, its own value is undefined, so the caller's value is erased. Inside an InputGroup, the caller's value is replaced with the group and input label ids.
  • Why does it hurt? The caller's extra context never reaches the trigger's accessible name.
  • Why does it matter? family:input-fields FR10.1 requires base aria-* props to reach the primary semantic control, which for Selector is the combobox trigger.

Fix: join the caller's ids after the field's own label, the same shape TimeInput uses. When a caller aria-labelledby is set, Field gets a labelID so the visible label stays in the name; aria-labelledby otherwise replaces the <label for> name.

Expected behavior and authority

  • family:input-fields FR10.1 (authority current): "aria-* … MUST reach the primary semantic control: the native input, textarea, or combobox/trigger element that carries the field's accessible name and value."
  • Same-family precedent for joining rather than replacing: TimeInput, RadioList, CheckboxList.

Smallest restoration

  • Selector.tsx: take aria-labelledby out of the spread props, join it after the field's own label with joinAriaIDs, and pass Field a labelID only when a caller value is set.
  • Selector.test.tsx: three cases (standalone, inside InputGroup, and unchanged without a caller value).
  • A patch changeset.

Without a caller aria-labelledby, the rendered attributes are unchanged. The listbox keeps aria-labelledby pointing at the trigger. component:Selector records no naming rule this changes. TextInput (#8707), NumberInput (#8708) and MultiSelector have the same defect and are fixed in separate pull requests.

Evidence

Chromium accessibility tree (CDP Accessibility.getPartialAXTree), Storybook served locally from main and from this branch, using a recording-only probe story (not committed) with a Lunch heading. Selector, MultiSelector, Field, InputGroup and inputAria are identical between d9b43cf24b, the main build served, and a73f0304b9, this branch's base.

Case main This branch
label="Fruit" aria-labelledby="lunch-heading" combobox "Fruit", no aria-labelledby combobox "Fruit Lunch", aria-labelledby="<label id> lunch-heading"
Same, inside InputGroup label="Order" "Order Fruit" "Order Fruit Lunch"
label="Fruit", no caller value "Fruit", no aria-labelledby unchanged
  • Reproduction before the change: on main, the caller's id is absent from the trigger.
  • Result after the change: the caller's id follows the field's own label in every case above. isLabelHidden still keeps "Fruit" in the name, and aria-labelledby="" leaves the name "Fruit".
  • Representative unchanged path: the trigger without a caller aria-labelledby, standalone and grouped.
  • Regression tests: the standalone and grouped cases fail with Selector.tsx reverted to main and pass with this change.

Both recordings use Playwright Chromium at the same 900 × 560 viewport and the same probe story. Each Tab stop's caption is read from Chrome's accessibility tree through CDP at that moment. The caption bar is recording-only.

AS-IS

selector-as-is.mp4

TO-BE

selector-to-be.mp4

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 exec vitest run --project ui packages/core/src/Selector packages/core/src/InputGroup packages/core/src/Field: 435 passed across 14 files.
  • pnpm -F @astryxdesign/core typecheck, eslint and prettier on the changed files, git diff --check: passed.
  • Chromium accessibility-tree probe of the cases above, main versus this branch.

Related Issues

Part of #8706

@vercel

vercel Bot commented Oct 27, 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 27, 2026 3:39pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 27, 2026, 4:10 PM UTC

@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Oct 27, 2026
@kyu-rong
kyu-rong marked this pull request as ready for review October 27, 2026 15:35
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 27, 2026

@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 looks ready to merge: Selector now passes a caller's aria-labelledby to the trigger after the field's own label, as family:input-fields FR10.1 requires, and the new standalone and InputGroup tests fail without the change and pass with it. Chromium's accessibility tree confirms the names, for example “Fruit Lunch” and “Order Fruit Lunch”, while triggers without a caller value are unchanged. One optional follow-up: a render test in a horizontal-labels FormLayout would cover the third layout FR10 lists; the fix already works there.

[Automated review]

@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

Component Size

Component Import before Import after Delta CSS before CSS after Delta
core/Pagination 87.7KB 87.8KB +29B 15.3KB 15.3KB 0B
core/PowerSearch 155.1KB 155.2KB +118B 18.6KB 18.6KB 0B
core/Selector 79.1KB 79.1KB +33B 15.0KB 15.0KB 0B
core/SelectorOption 14.5KB 14.5KB 0B 5.1KB 5.1KB 0B
richtext/RichTextEditorToolbar N/A 215.0KB N/A N/A 454B N/A

Sizes are gzip. Import counts the JavaScript the import loads eagerly; CSS counts the package stylesheet rules referenced by the modules it can load from its own package, lazily loaded ones included.

Bundle Size Summary

Gzip figures measure each package's entry file, not the code an import pulls in.

Package Entry (ESM) Entry gzip before Entry gzip after Delta
@astryxdesign/core 4.9KB 1.2KB 1.2KB 0B
Package stylesheet Gzip before Gzip after Delta
@astryxdesign/core 34.6KB 34.6KB 0B

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

8 of 14 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
Selector Indicator Space Popover Wide End RTL neutral light 204
Selector Indicator Space Popover Wide End RTL neutral dark 200
Selector Indicator Space Bottom Sheet Narrow End RTL neutral dark 153
Selector Indicator Space Bottom Sheet Wide Start neutral dark 123
Selector Indicator Space Popover Narrow Start neutral dark 93
Selector Indicator Space Popover Narrow Start neutral light 90

Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Oct 27, 2026
@cixzhang
cixzhang merged commit 619e4a5 into meta:main Oct 27, 2026
70 checks passed
cixzhang pushed a commit that referenced this pull request Oct 31, 2026
…ller aria-labelledby (#8862)

Follow-up to #8707, #8708, #8710 and #8711 (the #8706 family): the same bug on the Field-composed controls #8706 did not list.

TextArea, Typeahead and Tokenizer spread a caller's `aria-*` onto the control, so a caller's `aria-labelledby` becomes the control's only name and the field's own label is dropped. Probe on current main:

- `<TextArea label="Notes" aria-labelledby="b" />` has `aria-labelledby="b"`, so it is named "Billing", not "Notes Billing".
- `<Typeahead label="Fruit" aria-labelledby="b" />` is the same, and inside an `InputGroup` the group's label id is also lost.
- `<Tokenizer label="Members" aria-labelledby="b" />` is the same, for both the inline input and the compact trigger.

Fix, following #8707: destructure the caller's `aria-labelledby`, give the Field a `labelID`, and join the field's label id (or, in a group, the group and input label ids) with the caller's ids using `joinAriaIDs`. Controls without a caller `aria-labelledby` are unchanged.

Spec: `family:input-fields` FR10.1 ("`aria-*` ... MUST reach the primary semantic control").

Tests: one per component, plus a grouped Typeahead case. The four new tests fail without the change. TextArea, Typeahead and Tokenizer suites pass (384 tests), typecheck and eslint are clean. Non-visual, so no screenshots.

This branch was successfully deployed

1 active deployment
Preview — b863332f Deployed Oct 27, 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. community Authored by a community contributor (not on the eng/design team)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants