Skip to content

fix(TextInput): keep a caller aria-labelledby on the input - #8707

Merged
cixzhang merged 1 commit into
meta:mainfrom
kyu-rong:fix/text-input-caller-labelledby
Oct 28, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
kyu-rong:fix/text-input-caller-labelledby

Conversation

@kyu-rong

@kyu-rong kyu-rong commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

User impact

A builder who names a TextInput by a nearby heading, for example <TextInput label="Email" aria-labelledby="billing-heading" /> under a "Billing" heading, loses that name. Screen-reader users hear only "Email", so two Email fields in different sections of the same form sound identical.

Problem and solution fit

  • Why does it happen? TextInput writes its own aria-labelledby after the caller's props. Standalone, its own value is undefined, so the caller's value is erased. Inside an InputGroup, the caller's value is replaced with the group and input label ids.
  • Why does it hurt? The caller's extra context never reaches the accessible name.
  • Why does it matter? component:TextInput FR13 and family:input-fields FR10 require base aria-* props to reach the native input.

Fix: join the caller's ids after the field's own label, the same shape TimeInput uses. When a caller aria-labelledby is set, Field gets a labelID so the visible label stays in the name; aria-labelledby otherwise replaces the <label for> name.

Expected behavior and authority

  • component:TextInput FR13 (authority current): "Base props (ref, id, aria-*, …) reach the native input."
  • family:input-fields FR10.1 (authority current): "aria-* … MUST reach the primary semantic control."
  • Same-family precedent for joining rather than replacing: TimeInput, RadioList, CheckboxList.

Smallest restoration

  • TextInput.tsx: take aria-labelledby out of the spread props, join it after the field's own label with joinAriaIDs, and pass Field a labelID only when a caller value is set.
  • TextInput.test.tsx: three cases (standalone, inside InputGroup, and unchanged without a caller value).
  • TextInput.spec.md: FR13 and AR1 state where a caller aria-labelledby goes, and the Verification map row for FR13 lists the new cases.
  • A patch changeset.

Without a caller aria-labelledby, the rendered attributes are unchanged. NumberInput, Selector, and MultiSelector have the same defect and follow in separate pull requests.

Evidence

Chromium accessibility tree (CDP Accessibility.getPartialAXTree), Storybook served locally from main (d9b43cf24b) and from this branch, using a recording-only probe story (not committed) with a Billing heading:

Case main This branch
label="Email" aria-labelledby="billing-heading" name "Email", no aria-labelledby name "Email Billing", aria-labelledby="<label id> billing-heading"
Same, inside InputGroup label="Contact" name "Contact Email" name "Contact Email Billing"
label="Email", no caller value name "Email", no aria-labelledby unchanged
  • Reproduction before the change: on main, the caller's id is absent from the input.
  • Result after the change: the caller's id follows the field's own label in every case above. isLabelHidden still keeps "Email" in the name, and aria-labelledby="" leaves the name "Email".
  • Representative unchanged path: the input without a caller aria-labelledby, standalone and grouped.
  • Regression tests: the standalone and grouped cases fail with TextInput.tsx reverted to main and 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

textinput-as-is.mp4

TO-BE

textinput-to-be.mp4

Writing rubric results

  • R1 narration: none; the added sentences state where the name comes from.
  • R2 research: none.
  • R3 evidence: the FR13 verification cell names test cases, not a pull request.
  • R4 rejected alternatives: none.
  • R5 change references: none.
  • R6 open questions: none in the record.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm exec vitest run --project ui packages/core/src/TextInput packages/core/src/InputGroup packages/core/src/Field: 302 passed.
  • pnpm -F @astryxdesign/core typecheck, eslint and prettier on the changed files, pnpm check:knowledge, git diff --check: passed.
  • Chromium accessibility-tree probe of the cases above, main versus this branch.

Related Issues

Part of #8706

@vercel

vercel Bot commented Oct 27, 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 27, 2026 3:24pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 28, 2026, 4:36 PM UTC

@github-actions github-actions Bot added needs:spec-owner-review Current knowledge records await owner approval 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 27, 2026
@kyu-rong
kyu-rong marked this pull request as ready for review October 27, 2026 15:35
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 27, 2026

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

This restores a caller's aria-labelledby on TextInput, as component:TextInput FR13 and family:input-fields FR10.1 require. The new tests fail without the fix, Chromium's accessibility tree shows the expected names, and no defects were found. Approval waits on one spec decision: the new FR13/AR1 sentence that a caller aria-labelledby follows the field's own label sets an order the current TextInput spec does not state. An engineering owner records that decision by commenting /approve-spec 6f26417760fdfca5ff0a83cb1a87af108f2effbb on this pull request (the author may do so if they are an engineering owner); if they choose another order, the code, tests, spec sentences and changeset change with it.

[Automated review]

@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

TextInput (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Entry File (ESM) 480B 480B 0B
Lines of Code 381 389 -
Complexity Very High Very High (73) -

Component Size

Component Import before Import after Delta CSS before CSS after Delta
core/PowerSearch 155.1KB 155.1KB +48B 18.6KB 18.6KB 0B
core/TextInput 53.5KB 53.6KB +49B 10.5KB 10.5KB 0B
lab/ChatEmojiPicker N/A 64.8KB N/A N/A 773B N/A
lab/ChatReactionBar N/A 65.4KB N/A N/A 1.1KB N/A
lab/CommentComposer N/A 93.6KB N/A N/A 1.9KB N/A
lab/CommentThread N/A 215.3KB N/A N/A 2.4KB N/A
lab/Comments N/A 219.9KB N/A N/A 2.5KB N/A
lab/EmojiPicker N/A 62.9KB N/A N/A 722B N/A
lab/MobilePowerSearch N/A 159.7KB N/A N/A 1.4KB N/A
lab/MobileTokenizer N/A 91.2KB N/A N/A 775B N/A
lab/TransferList N/A 66.7KB N/A N/A 1.7KB N/A
lab/TransferListSelector N/A 72.3KB N/A N/A 1.9KB N/A
richtext/RichTextEditorToolbar N/A 215.1KB N/A N/A 454B 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 34.6KB 34.6KB 0B

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

Status: No visual change across 4 compared shot(s).


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 6f26417

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Oct 28, 2026

@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 needed: this restores a caller's aria-labelledby on TextInput as component:TextInput FR13 and family:input-fields FR10.1 require, and the label-first order it adds to FR13 and AR1 has an engineering owner's /approve-spec for this head. The new standalone and grouped tests fail without the fix and pass with it, and Chromium's accessibility tree names the fields “Email Billing” and “Contact Email Billing”, as the changeset says. Merging still needs the repository's regular code review.

[Automated review]

@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 28, 2026
@cixzhang
cixzhang merged commit a8374b5 into meta:main Oct 28, 2026
73 checks passed
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 28, 2026
TextInput.tsx conflicted only in its imports: main's meta#8707 (a caller's
aria-labelledby stays on the input) imports joinAriaIDs where this branch
imports the text-entry trait attributes. Both imports kept; meta#8707's behavior
and tests are unchanged.
cixzhang pushed a commit that referenced this pull request Oct 31, 2026
…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.

This branch was successfully deployed

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

Labels

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