Skip to content

fix(NumberInput): keep a caller aria-labelledby on the input - #8708

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

cixzhang merged 1 commit into
meta:mainfrom
kyu-rong:fix/number-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 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

  • Why does it happen? NumberInput 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? family:input-fields FR10 requires base aria-* props to reach the native input, and component:NumberInput FR12 holds its prop targets to component:TextInput FR13.

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

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

Smallest restoration

  • NumberInput.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.
  • NumberInput.test.tsx: three cases (standalone, inside InputGroup, and unchanged without a caller value).
  • A patch changeset.

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 from main (d9b43cf24b) and from this branch, using a recording-only probe story (not committed) with a Billing heading:

Case main This branch
label="Amount" aria-labelledby="billing-heading" spinbutton "Amount", no aria-labelledby spinbutton "Amount Billing", aria-labelledby="<label id> billing-heading"
Same, inside InputGroup label="Price" "Price Amount" "Price Amount Billing"
label="Amount", no caller value "Amount", 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 "Amount" in the name, and aria-labelledby="" leaves the name "Amount".
  • Representative unchanged path: the input without a caller aria-labelledby, standalone and grouped.
  • Regression tests: the standalone and grouped cases fail with NumberInput.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

numberinput-as-is.mp4

TO-BE

numberinput-to-be.mp4

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/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.
  • 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:27pm 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 27, 2026, 3:59 PM UTC

@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 27, 2026
@kyu-rong
kyu-rong marked this pull request as ready for review October 27, 2026 15:35

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

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 27, 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

NumberInput (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Entry File (ESM) 502B 502B 0B
Lines of Code 1144 1152 -
Complexity Very High Very High (176) -

Component Size

Component Import before Import after Delta CSS before CSS after Delta
core/NumberInput 55.7KB 55.7KB +38B 10.7KB 10.7KB 0B
core/Pagination 87.7KB 87.8KB +41B 15.3KB 15.3KB 0B
core/PowerSearch 155.1KB 155.2KB +102B 18.6KB 18.6KB 0B
lab/MobilePowerSearch N/A 159.7KB 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 34.6KB 34.6KB 0B

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

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


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 27, 2026
@cixzhang
cixzhang merged commit f30564c into meta:main Oct 27, 2026
70 checks passed
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 — ba8db711 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