Skip to content

fix(TextArea, Typeahead, Tokenizer): keep the field's label with a caller aria-labelledby - #8862

Merged
cixzhang merged 3 commits into
meta:mainfrom
HelloOjasMutreja:fix/fields-keep-aria-labelledby
Oct 31, 2026
Merged

cixzhang merged 3 commits into
meta:mainfrom
HelloOjasMutreja:fix/fields-keep-aria-labelledby

Conversation

@HelloOjasMutreja

Copy link
Copy Markdown
Contributor

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.

@vercel

vercel Bot commented Oct 28, 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 29, 2026 8:24pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 28, 2026
@astracat-bot

astracat-bot Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 29, 2026, 8:41 PM UTC

@HelloOjasMutreja
HelloOjasMutreja marked this pull request as ready for review October 29, 2026 02:23

@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.

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.

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.

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).

@HelloOjasMutreja

Copy link
Copy Markdown
Contributor Author

Pushed d2b6155: the changeset now names the target (WCAG 2.2 SC 2.5.3 Label in Name; family:input-fields FR10.1) and states the Typeahead-in-InputGroup case, which ignored the caller's ids, using your suggested wording.

@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.

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}

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.

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();

@HelloOjasMutreja

Copy link
Copy Markdown
Contributor Author

Pushed 181a489: TokenizerBottomSheet.test.tsx now has a case that renders the sheet presentation with a caller aria-labelledby and expects the trigger button to be named "Tags Billing". With the aria-labelledby on the trigger removed it fails, and with it in place it passes. The commit also carries four brace-only changes to existing for (...) cb(); lines in that file, from the repo's lint-staged eslint fix.

@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.

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();}

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.

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();
      }

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Oct 31, 2026
@cixzhang cixzhang closed this Oct 31, 2026
@cixzhang cixzhang reopened this Oct 31, 2026
@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 31, 2026
@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

TextArea (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Entry File (ESM) 455B 455B 0B
Lines of Code 462 471 -
Complexity Very High Very High (74) -
Tokenizer (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Entry File (ESM) 331B 331B 0B
Lines of Code 1923 1933 -
Complexity Very High Very High (310) -

Component Size

Component Import before Import after Delta CSS before CSS after Delta
core/BaseTypeahead 55.8KB 55.8KB 0B 10.1KB 10.1KB 0B
core/PowerSearch 168.0KB 168.0KB +47B 20.1KB 20.1KB 0B
core/TextArea 50.0KB 50.1KB +107B 9.5KB 9.5KB 0B
core/Tokenizer 69.8KB 69.9KB +136B 16.7KB 16.7KB 0B
core/Typeahead 63.0KB 63.0KB +17B 11.4KB 11.4KB 0B
core/TypeaheadItem 6.2KB 6.2KB 0B 3.4KB 3.4KB 0B
lab/MobilePowerSearch N/A 148.4KB N/A N/A 1.4KB N/A

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 35.4KB 35.4KB 0B

Accessibility Audit

Status: The accessibility audit did not run on this pull request. It runs after merges to main and before each release; pull requests that touch components run it with the ci:heavy-lanes label.


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 31, 2026
@cixzhang
cixzhang merged commit 75001c5 into meta:main Oct 31, 2026
59 checks passed
cixzhang added a commit that referenced this pull request Oct 31, 2026
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.

This branch was successfully deployed

1 active deployment
Preview — 181a4897 Deployed Oct 29, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) 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