Repository navigation
fix(MultiSelector): keep a caller aria-labelledby on the trigger - #8711
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
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]
There was a problem hiding this comment.
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]
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewModified ComponentsMultiSelector (@astryxdesign/core) · View in Storybook
Component Size
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 SummaryGzip figures measure each package's entry file, not the code an import pulls in.
Accessibility AuditStatus: No accessibility violations detected. Visual RegressionStatus: No visual change across 2 compared shot(s). Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
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.
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.
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.
…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.
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
aria-labelledby. Standalone, its own value isundefined, so the caller's value is erased. Inside an InputGroup, the caller's value is replaced with the group and input label ids.family:input-fieldsFR10.1 requires basearia-*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-labelledbyis set, Field gets alabelIDso the visible label stays in the name;aria-labelledbyotherwise replaces the<label for>name.The
renderTriggerpath already handed the caller'saria-labelledbyto the caller's control through the spread props. Takingaria-labelledbyout 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 ownaria-labelledbybefore spreading the props keeps it.Expected behavior and authority
family:input-fieldsFR10.1 (authoritycurrent): "aria-*… MUST reach the primary semantic control: the native input, textarea, or combobox/trigger element that carries the field's accessible name and value."TimeInput,RadioList,CheckboxList.Smallest restoration
MultiSelector.tsx: takearia-labelledbyout of the spread props, join it after the field's own label withjoinAriaIDson the built-in trigger, pass it torenderTriggeronly when the caller set one, and pass Field alabelIDonly when a caller value is set.MultiSelector.test.tsx: five cases (standalone, inside InputGroup, unchanged without a caller value,renderTriggerwith a caller value, and arenderTriggercontrol whose ownaria-labelledbysurvives the spread).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 frommainand from this branch, using a recording-only probe story (not committed) with aLunchheading. Selector, MultiSelector, Field, InputGroup andinputAriaare identical betweend9b43cf24b, themainbuild served, anda73f0304b9, this branch's base.mainlabel="Fruits" aria-labelledby="lunch-heading"aria-labelledbyaria-labelledby="<label id> lunch-heading"InputGroup label="Order"label="Fruits", no caller valuearia-labelledbyrenderTrigger+aria-labelledby="lunch-heading"aria-labelledby="lunch-heading"renderTriggercontrol with its ownaria-labelledby="row-title", no caller valuearia-labelledby="row-title"main, the caller's id is absent from the built-in trigger.renderTriggercontrol is unchanged.isLabelHiddenstill keeps "Fruits" in the name, andaria-labelledby=""leaves the name "Fruits".aria-labelledby, and therenderTriggercontrol.MultiSelector.tsxreverted tomain. TherenderTriggercaller-value case fails when only the explicit pass-through is removed. The own-aria-labelledbycase fails on the previous head (45edb5eec9), which handed backaria-labelledby: undefined, and passes onmainand here; the last table row was measured against amainbuild ata73f0304b9. 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
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.mainversus this branch.Related Issues
Part of #8706