fix(core): announce PowerSearch result counts to screen readers#3726
Open
bhamodi wants to merge 1 commit into
Open
fix(core): announce PowerSearch result counts to screen readers#3726bhamodi 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. |
2ab915e to
2e00998
Compare
2e00998 to
e866964
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
PowerSearchaccepts aresultCountprop -- "Number of results matching the current filters" -- and renders it as a plain<span>in the input's end content (PowerSearch.tsx:949-975). This is a different number from the combobox dropdown's suggestion count: it reports how many rows in the consumer's dataset match the currently-applied filters (e.g.resultCount={filtered.length}in the table templates). It was shown only visually and never announced, so a screen-reader user who added or removed a filter got no signal that the underlying result set had changed size.The dropdown's own suggestion count is already handled:
PowerSearchdelegates its combobox toBaseTypeahead, which announces the number of matching field suggestions as you type via the repo'suseAnnouncehook (BaseTypeahead.tsx:428-439). That path covers a distinct set (the autocomplete options), not theresultCountprop, so the gap was real. This change brings theresultCountvalue to parity, routing it through the same hook and its persistently-mounted polite live region.To keep the visible label and the announcement from drifting, both now derive from a single
resultCountTextmemo (numbers formatted as"N results"/"1 result", strings passed through verbatim). An effect announces that text on change and skips the initial render, so the count already present on mount is not announced unprompted -- only user-driven changes are spoken. The two announce paths fire at different times (typing narrows the dropdown; applying a filter changesresultCount), so there is no double-announcement.Changes
PowerSearch/PowerSearch.tsx: importuseAnnounce; extract a sharedresultCountTextstring used by both the visible<span>and the announcement; add an effect that announces result-count changes politely (skipping mount). No new prop, no visual change.PowerSearch/PowerSearch.doc.mjs: note the polite-live-region behavior on theresultCountprop (English + Chinese).Test plan
node_modules/.bin/vitest run --root . packages/core/src/PowerSearch packages/core/src/Typeahead-- 154 pass (149 before). Five new tests underPowerSearch > result count announcements:resultCountchanges ("5 results")/results/so it cannot pass on a plural "1 results")resultCountverbatim ("Showing 1.2k matches")BaseTypeahead's dropdown announcement intact and stays silent whenresultCountis unsetnode_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. The announcement reuses
BaseTypeahead's wording (`${n} result${n === 1 ? '' : 's'}`) but renders the number withIntl.NumberFormatso it matches the existing visible label exactly.