Skip to content

fix(#4450): give Selector trigger an accessible name via aria-labelledby - #4604

Closed
gonzoblasco wants to merge 1 commit into
meta:mainfrom
gonzoblasco:fix/selector-accessible-name
Closed

gonzoblasco wants to merge 1 commit into
meta:mainfrom
gonzoblasco:fix/selector-accessible-name

Conversation

@gonzoblasco

Copy link
Copy Markdown
Contributor

What

Fixes #4450 — the Selector trigger button had no accessible name in either mode:

  • Without hasSearch: role=combobox (not name-from-content), no aria-label or aria-labelledby → empty accessible name
  • With hasSearch: plain <button> (name-from-content), but the name fell back to the placeholder text instead of the actual label prop

Changes

  • Generate a fieldLabelId with useId() in the Selector
  • Pass it to <Field> as labelID so the rendered label element carries a stable id
  • Use it as aria-labelledby on the trigger button when standalone (no InputGroup)
  • InputGroup mode preserves the existing ariaLabelledBy composition

Validation

  • pnpm test -- --run packages/core/src/Selector/Selector.test.tsx: 46/46 tests pass
  • pnpm lint: clean
  • pnpm check:sync: clean
  • pnpm check:package-boundaries: clean

Fixes #4450

@vercel

vercel Bot commented Jul 31, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview Aug 6, 2026 11:13pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 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 needs:design-review Affects visuals — Design should review labels Jul 31, 2026
@gonzoblasco
gonzoblasco force-pushed the fix/selector-accessible-name branch from 97831a5 to 9da9552 Compare August 3, 2026 15:19

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

(Sorry the original comment was posted accidentally by AI, now updated with verified feedbacks)

Thanks for the fix. Two things to address:

  • This branch also includes the unrelated contrast-token changes and audit scripts from #4022. Please rebase or cherry-pick the Selector commit onto main.
  • Before this patch, the native association already gives the trigger the accessible name Fruit in the repository’s accessibility tests, across both hasSearch modes. Could you document the specific compatibility case where explicit aria-labelledby is needed, and add a regression if the tooling can represent it?

@imdreamrunner
imdreamrunner self-requested a review August 6, 2026 22:14
…elledby

The Selector trigger button had no accessible name in either mode:
- Without hasSearch: role=combobox (not name-from-content), no
  aria-label/aria-labelledby -> empty name
- With hasSearch: plain button, name fell back to placeholder text
  instead of the actual label

Fix: generate a fieldLabelId with useId(), pass it to Field as labelID,
and use it as aria-labelledby on the trigger button when standalone
(no InputGroup). For InputGroup mode the existing ariaLabelledBy
composition is preserved.
@gonzoblasco
gonzoblasco force-pushed the fix/selector-accessible-name branch from 9da9552 to 6efdf41 Compare August 6, 2026 23:10
@gonzoblasco

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review, @imdreamrunner. You're right on both counts.

The branch is now clean - I rebased the Selector commit onto current main, so #4604 only contains the single aria-labelledby change to Selector.tsx (the contrast work from #4022 is no longer in this branch).

On the accessible name finding: you're correct that the change is redundant. The evidence came from automated static audit (axe), not from a real browser/AT failure, and your verification confirms the native <label for> + <button id> association already provides the accessible name and the suite passes 70/70 at the parent commit. Since there's no concrete failing case to justify explicit ARIA, I'm closing this as already satisfied rather than keeping redundant wiring in the codebase.

Thanks for the detailed review.

@gonzoblasco gonzoblasco closed this Aug 6, 2026
@github-actions github-actions Bot removed the needs:design-review Affects visuals — Design should review label Aug 6, 2026
@gonzoblasco
gonzoblasco deleted the fix/selector-accessible-name branch August 10, 2026 15:17

This branch was successfully deployed

1 active deployment
Preview — 6efdf41b Deployed Aug 6, 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) needs:code-review High-risk change (new package/component/API) — needs human code review before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Selector's trigger has no accessible name, and its role changes with hasSearch

2 participants