Repository navigation
fix(Selector): keep a caller aria-labelledby on the trigger - #8710
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.
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]
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewComponent 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 Regression8 of 14 shot(s) changed. A change here is a question, not a failure: check whether the after is the
Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
…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 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
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 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-labelledbyis set, Field gets alabelIDso the visible label stays in the name;aria-labelledbyotherwise replaces the<label for>name.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
Selector.tsx: takearia-labelledbyout of the spread props, join it after the field's own label withjoinAriaIDs, and pass Field alabelIDonly when a caller value is set.Selector.test.tsx: three cases (standalone, inside InputGroup, and unchanged without a caller value).Without a caller
aria-labelledby, the rendered attributes are unchanged. The listbox keepsaria-labelledbypointing at the trigger.component:Selectorrecords 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 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="Fruit" aria-labelledby="lunch-heading"aria-labelledbyaria-labelledby="<label id> lunch-heading"InputGroup label="Order"label="Fruit", no caller valuearia-labelledbymain, the caller's id is absent from the trigger.isLabelHiddenstill keeps "Fruit" in the name, andaria-labelledby=""leaves the name "Fruit".aria-labelledby, standalone and grouped.Selector.tsxreverted tomainand 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
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.mainversus this branch.Related Issues
Part of #8706