fix(core): announce Selector search result counts to screen readers#3725
Open
bhamodi wants to merge 1 commit into
Open
fix(core): announce Selector search result counts to screen readers#3725bhamodi wants to merge 1 commit into
bhamodi wants to merge 1 commit into
Conversation
|
@bhamodi is attempting to deploy a commit to the Meta Open Source Team on Vercel. A member of the Team first needs to authorize it. |
988bdae to
009c67f
Compare
009c67f to
64818b6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In
hasSearchmode, typing into theSelectorpopover's search input filters the option list silently. ThefilteredItemsmemo recomputes on every keystroke (Selector.tsx:640-648) andrenderOptionsswaps in a visual "No results found" empty state (Selector.tsx:911), but nothing was announced to assistive technology -- the file never importeduseAnnounce. A screen-reader user narrowing a long list heard only their own typing, with no signal for how many options remained or that the list had emptied.Typeaheadalready gives this feedback:BaseTypeaheadannounces result counts as you type via the repo'suseAnnouncehook (BaseTypeahead.tsx:431-438). This bringsSelectorto parity, reusing the exact same strings --`${n} result${n === 1 ? '' : 's'}`and"No results found"-- routed through the same hook and its persistently-mounted polite live region.An effect keys off the existing
filteredItemsmemo and the search state (Selector.tsx:691-706), so it covers every way the filtered list changes through one code path and adds no new prop or render branch. It announces only while the popover is open with a non-empty query; when the query is emptied or the popover closes it clears the region so stale status text does not linger.Changes
Selector/Selector.tsx: importuseAnnounce; add an effect that announces"3 results"/"1 result"/"No results found"politely while searching (matchingBaseTypeahead's exact wording), and clears the region when the search context goes away.Test plan
node_modules/.bin/vitest run --root . packages/core/src/Selector-- 49 pass (Selector.test.tsx). Four new tests underhasSearch > result announcements:/^1 result$/so it cannot pass on a plural "1 results")node_modules/.bin/tsc --project packages/core/tsconfig.json --noEmit-- clean.node_modules/.bin/eslinton changed files -- clean.Notes
Found during a broader a11y audit of core components; scoped to one fix per PR (does not add the separate Home/End key-handling finding or touch other Selector behavior).
Selector.doc.mjswas left unchanged: no new props were added and it has no accessibility/features section, matching how the analogousTypeaheadannounce behavior is not documented there either.