Skip to content

fix(MultiSelector): keep a caller aria-labelledby on the trigger - #8711

Merged
cixzhang merged 2 commits into
meta:mainfrom
kyu-rong:fix/multi-selector-caller-labelledby
Oct 27, 2026
Merged

cixzhang merged 2 commits into
meta:mainfrom
kyu-rong:fix/multi-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 MultiSelector by a nearby heading, for example <MultiSelector label="Fruits" aria-labelledby="lunch-heading" /> under a "Lunch" heading, loses that name on the built-in trigger. Screen-reader users hear only "Fruits", so two pickers in different sections of the same form sound identical.

Problem and solution fit

  • Why does it happen? MultiSelector builds the built-in 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 the built-in trigger is the combobox.

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.

The renderTrigger path already handed the caller's aria-labelledby to the caller's control through the spread props. Taking aria-labelledby out of those props would drop it there, so that path now passes it explicitly, and only when the caller set one, so a control that names itself with its own aria-labelledby before spreading the props keeps it.

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

  • MultiSelector.tsx: take aria-labelledby out of the spread props, join it after the field's own label with joinAriaIDs on the built-in trigger, pass it to renderTrigger only when the caller set one, and pass Field a labelID only when a caller value is set.
  • MultiSelector.test.tsx: five cases (standalone, inside InputGroup, unchanged without a caller value, renderTrigger with a caller value, and a renderTrigger control whose own aria-labelledby survives the spread).
  • A patch changeset.

Without a caller aria-labelledby, the rendered attributes are unchanged. TextInput (#8707), NumberInput (#8708) and Selector 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="Fruits" aria-labelledby="lunch-heading" combobox "Fruits", no aria-labelledby combobox "Fruits Lunch", aria-labelledby="<label id> lunch-heading"
Same, inside InputGroup label="Order" "Order Fruits" "Order Fruits Lunch"
label="Fruits", no caller value "Fruits", no aria-labelledby unchanged
renderTrigger + aria-labelledby="lunch-heading" button "Lunch", aria-labelledby="lunch-heading" unchanged
renderTrigger control with its own aria-labelledby="row-title", no caller value button "Lunch fruits", aria-labelledby="row-title" unchanged
  • Reproduction before the change: on main, the caller's id is absent from the built-in trigger.
  • Result after the change: the caller's id follows the field's own label on the built-in trigger, and the renderTrigger control is unchanged. isLabelHidden still keeps "Fruits" in the name, and aria-labelledby="" leaves the name "Fruits".
  • Representative unchanged path: the trigger without a caller aria-labelledby, and the renderTrigger control.
  • Regression tests: the standalone and grouped cases fail with MultiSelector.tsx reverted to main. The renderTrigger caller-value case fails when only the explicit pass-through is removed. The own-aria-labelledby case fails on the previous head (45edb5eec9), which handed back aria-labelledby: undefined, and passes on main and here; the last table row was measured against a main build at a73f0304b9. All 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

multiselector-as-is.mp4

TO-BE

multiselector-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/MultiSelector packages/core/src/InputGroup packages/core/src/Field: 405 passed across 11 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 4:17pm 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:45 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.

Changes requested for one regression; the main fix is right, and a caller's aria-labelledby now follows the field label on the built-in trigger ("Fruits Lunch", or "Order Fruits Lunch" inside an InputGroup). In the renderTrigger props, 'aria-labelledby': ariaLabelledByProp (MultiSelector.tsx:2497) is set even when no value was passed, so a control that names itself with its own aria-labelledby before {...props} loses that attribute, and an icon-only opener ends up with no accessible name. Please add the key only when a value was passed, for example ...(ariaLabelledByProp != null ? {'aria-labelledby': ariaLabelledByProp} : null), and add a test where the control's own aria-labelledby survives the spread.

[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 looks ready to approve: a caller's aria-labelledby now follows the field's label on MultiSelector's built-in trigger ("Fruits Lunch", or "Order Fruits Lunch" inside an InputGroup), as family:input-fields FR10.1 asks, and renderTrigger controls receive exactly what they did before. The earlier renderTrigger regression is fixed and covered by the new own-label test. No further changes are needed.

[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

Modified Components

MultiSelector (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Entry File (ESM) 273B 273B 0B
Lines of Code 2631 2642 -
Complexity Very High Very High (344) -

Component Size

Component Import before Import after Delta CSS before CSS after Delta
core/MultiSelector 76.2KB 76.2KB +53B 14.6KB 14.6KB 0B

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

Status: No visual change across 2 compared shot(s).


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 e200d6f into meta:main Oct 27, 2026
67 checks passed
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 27, 2026
Main's meta#8711 appended a 'MultiSelector caller aria-labelledby' suite to MultiSelector.test.tsx where this branch appends its own; the file keeps main's suite as is, then this branch's cases.
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 27, 2026
Main's meta#8711 appended a 'MultiSelector caller aria-labelledby' suite to MultiSelector.test.tsx where this branch appends its own; the file keeps main's suite as is, then this branch's cases.
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 27, 2026
Main's meta#8711 appended a 'MultiSelector caller aria-labelledby' suite to MultiSelector.test.tsx where this branch appends its own; the file keeps main's suite as is, then this branch's cases.
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 — c95af28e 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