Repository navigation
fix(TextArea, Typeahead, Tokenizer): keep the field's label with a caller aria-labelledby - #8862
Conversation
…ller aria-labelledby
|
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.
The fix itself is right: with a caller aria-labelledby, TextArea, Typeahead (standalone and inside an InputGroup) and Tokenizer now keep the visible label first in the accessible name, and the new tests fail without the change. One change is needed before merge: the changeset should name the accessibility target this fix serves (for example WCAG 2.2 SC 2.5.3 Label in Name and family:input-fields FR10.1), as spec:AST-017 FR53 asks of accessibility fixes. Its "Before" sentence should also cover a Typeahead inside an InputGroup, which previously ignored the caller's ids rather than being named by them.
[Automated review]
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [fix] TextArea, Typeahead and Tokenizer: a caller's `aria-labelledby` no longer replaces the field's own label. Before, it was the only name the control had, so `label="Notes" aria-labelledby="billing-heading"` named the textarea "Billing". Now the caller's ids follow the field's own label ("Notes Billing"), and a Typeahead inside an InputGroup is named by the group, its label, then the caller's ids, as TextInput, NumberInput, Selector and MultiSelector already are. Fields without a caller `aria-labelledby` are unchanged. No API changes. |
There was a problem hiding this comment.
spec:AST-017 FR53 asks an accessibility fix's changeset to name the old and new behavior and the accessibility target it serves. This entry names no target, and "it was the only name the control had" does not hold for a Typeahead inside an InputGroup, which ignored the caller's ids (your grouped test case is named "Contact Fruit" without this change). For example:
…; a Typeahead inside an InputGroup, which ignored the caller's ids, is now named by the group, its label, then the caller's ids. The visible label stays in the name (WCAG 2.2 SC 2.5.3 Label in Name; `family:input-fields` FR10.1).
|
Pushed d2b6155: the changeset now names the target (WCAG 2.2 SC 2.5.3 Label in Name; |
There was a problem hiding this comment.
The fix itself is right: with a caller aria-labelledby, TextArea, Typeahead (standalone and inside an InputGroup) and Tokenizer now keep the visible label first in the accessible name, the new tests fail without the change, and the updated changeset names the accessibility target and the grouped Typeahead case. One change is needed before merge: the Tokenizer sheet trigger's new aria-labelledby (Tokenizer.tsx:1470) has no test, and nothing in the suite fails if that line is removed, while architecture:component-test-sufficiency INV3 asks a behavior fix to carry a regression test. Please add one case to TokenizerBottomSheet.test.tsx that renders TokenizerWithPresentation with experimental={{presentation: 'bottom-sheet'}} and a caller aria-labelledby, and expects the trigger button to be named by the label followed by the caller's text (for example "Tags Billing").
[Automated review]
| ref={triggerMergedRef} | ||
| type="button" | ||
| id={inputId} | ||
| aria-labelledby={fieldLabelledBy} |
There was a problem hiding this comment.
No test covers this join: with this line removed, every Tokenizer test still passes, so a later edit could drop the caller's ids from the sheet trigger's name unnoticed (architecture:component-test-sufficiency INV3 asks a fix to carry a regression test). A case like this in TokenizerBottomSheet.test.tsx passes with this change and fails without this line:
render(
<>
<span id="billing-heading">Billing</span>
<TokenizerWithPresentation
label="Tags"
searchSource={source}
value={[]}
onChange={() => {}}
aria-labelledby="billing-heading"
experimental={{presentation: 'bottom-sheet'}}
/>
</>,
);
expect(screen.getByRole('button', {name: 'Tags Billing'})).toBeInTheDocument();|
Pushed 181a489: |
There was a problem hiding this comment.
No changes are needed: with a caller aria-labelledby, TextArea, Typeahead (standalone and inside an InputGroup) and Tokenizer, including its sheet trigger, now keep the visible label first in the accessible name, and each new naming test fails without the change it covers. One optional cleanup: the four brace-only lines added to TokenizerBottomSheet.test.tsx (for (const cb of listeners) {cb();}) don't match the repository's Prettier output, so running Prettier on that file would keep it clean for the next edit.
[Automated review]
| compact = false; | ||
| act(() => { | ||
| for (const cb of listeners) cb(); | ||
| for (const cb of listeners) {cb();} |
There was a problem hiding this comment.
Optional: Prettier writes this loop on three lines, so with this line and the same edit at 2545, 2553 and 2560 the file fails the repository's prettier --check (the base file passes). Running Prettier on this file restores it:
for (const cb of listeners) {
cb();
}
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewModified ComponentsTextArea (@astryxdesign/core) · View in Storybook
Tokenizer (@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: The accessibility audit did not run on this pull request. It runs after merges to Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
Main's #8862 fix names the input with the field label plus a caller aria-labelledby, and sets Field's labelID only for that case. The value token's button now takes the same name plus the value (with a test), and labelID is always set because the token references the field label. Token tests keep both sides.
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'saria-labelledbybecomes the control's only name and the field's own label is dropped. Probe on current main:<TextArea label="Notes" aria-labelledby="b" />hasaria-labelledby="b", so it is named "Billing", not "Notes Billing".<Typeahead label="Fruit" aria-labelledby="b" />is the same, and inside anInputGroupthe 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 alabelID, and join the field's label id (or, in a group, the group and input label ids) with the caller's ids usingjoinAriaIDs. Controls without a calleraria-labelledbyare unchanged.Spec:
family:input-fieldsFR10.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.