Repository navigation
fix(NumberInput): keep a caller aria-labelledby on the input - #8708
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 looks ready to merge: NumberInput now passes a caller's aria-labelledby through to the input after the field's own label, standalone and inside an InputGroup, which restores what family:input-fields FR10.1 and component:TextInput FR13 require. The two new naming tests fail without the fix and pass with it, and the accessible names in your evidence hold up, including the hidden-label case, while inputs without a caller value are unchanged. Nothing further is needed from you here.
[Automated review]
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewModified ComponentsNumberInput (@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 6 compared shot(s). 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 NumberInput by a nearby heading, for example
<NumberInput label="Amount" aria-labelledby="shipping-heading" />under a "Shipping" heading, loses that name. Screen-reader users hear only "Amount", so two Amount fields in different sections of the same form sound identical.Problem and solution fit
aria-labelledbyafter the caller's props. 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 requires basearia-*props to reach the native input, andcomponent:NumberInputFR12 holds its prop targets tocomponent:TextInputFR13.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."component:NumberInputFR12 (authoritycurrent): prop targets matchcomponent:TextInputFR13, "Base props (ref,id,aria-*, …) reach the native input."TimeInput,RadioList,CheckboxList.Smallest restoration
NumberInput.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.NumberInput.test.tsx: three cases (standalone, inside InputGroup, and unchanged without a caller value).Without a caller
aria-labelledby, the rendered attributes are unchanged. TextInput, Selector, and MultiSelector have the same defect and are fixed in separate pull requests.Evidence
Chromium accessibility tree (CDP
Accessibility.getPartialAXTree), Storybook served locally frommain(d9b43cf24b) and from this branch, using a recording-only probe story (not committed) with aBillingheading:mainlabel="Amount" aria-labelledby="billing-heading"aria-labelledbyaria-labelledby="<label id> billing-heading"InputGroup label="Price"label="Amount", no caller valuearia-labelledbymain, the caller's id is absent from the input.isLabelHiddenstill keeps "Amount" in the name, andaria-labelledby=""leaves the name "Amount".aria-labelledby, standalone and grouped.NumberInput.tsxreverted tomainand pass with this change.Both recordings use Playwright Chromium at the same 900 × 520 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
numberinput-as-is.mp4
TO-BE
numberinput-to-be.mp4
Scope
Testing
pnpm exec vitest run --project ui packages/core/src/NumberInput packages/core/src/InputGroup packages/core/src/Field: 499 passed.pnpm -F @astryxdesign/core typecheck, eslint and prettier on the changed files,pnpm check:knowledge,git diff --check: passed.mainversus this branch.Related Issues
Part of #8706