Repository navigation
Fix: Screen reader does not announce search suggestions in Settings > Security - #83096
marufsharifi wants to merge 9 commits into
Conversation
|
Hey, I noticed you changed If you want to automatically generate translations for other locales, an Expensify employee will have to:
Alternatively, if you are an external contributor, you can run the translation script locally with your own OpenAI API key. To learn more, try running: npx ts-node ./scripts/generateTranslations.ts --helpTypically, you'd want to translate only what you changed by running |
|
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers! |
…lized status strings
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
|
@marufsharifi how's this one lookin? is this ready for review? |
|
|
||
| const scrollTimeoutRef = useRef<NodeJS.Timeout | null>(null); | ||
|
|
||
| useEffect(() => { |
There was a problem hiding this comment.
❌ CONSISTENCY-3 (docs)
The entire suggestions-announcement logic — suggestionsAnnouncement state, lastAnnouncementKeyRef, isMacOSChromeWeb detection, the useEffect with platform branching, and the <Text> live-region JSX — is copy-pasted nearly identically across four components:
AddressSearch/index.tsxSelectionList/BaseSelectionList.tsxSelectionList/SelectionListWithSections/BaseSelectionListWithSections.tsxSelectionListWithSections/BaseSelectionListWithSections.tsx
Extract this into a reusable custom hook (e.g. useSuggestionsAnnouncement) that encapsulates the state, effect, and returns the announcement JSX element. This would also let you create platform-specific implementations (.web.ts / .native.ts) to eliminate inline Platform.OS checks.
Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
| lastAnnouncementKeyRef.current = announcementKey; | ||
| const announcementText = translate('search.suggestionsAvailable'); | ||
| if (Platform.OS === CONST.PLATFORM.WEB) { | ||
| // eslint-disable-next-line react-hooks/set-state-in-effect |
There was a problem hiding this comment.
❌ CONSISTENCY-5 (docs)
eslint-disable-next-line react-hooks/set-state-in-effect lacks an accompanying justification comment. Add a reason, e.g.:
// setState is intentional here — the live-region text must differ on each trigger so screen readers re-announce it.
// eslint-disable-next-line react-hooks/set-state-in-effectPlease rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
| lastAnnouncementKeyRef.current = announcementKey; | ||
| const announcementText = translate('search.suggestionsAvailable', {count: data.length}); | ||
| if (Platform.OS === CONST.PLATFORM.WEB) { | ||
| // eslint-disable-next-line react-hooks/set-state-in-effect |
There was a problem hiding this comment.
❌ CONSISTENCY-5 (docs)
eslint-disable-next-line react-hooks/set-state-in-effect lacks an accompanying justification comment. Add a reason explaining why calling setState inside this useEffect is intentional.
Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
| lastAnnouncementKeyRef.current = announcementKey; | ||
| const announcementText = translate('search.suggestionsAvailable', {count: itemsCount}); | ||
| if (Platform.OS === CONST.PLATFORM.WEB) { | ||
| // eslint-disable-next-line react-hooks/set-state-in-effect |
There was a problem hiding this comment.
❌ CONSISTENCY-5 (docs)
eslint-disable-next-line react-hooks/set-state-in-effect lacks an accompanying justification comment. Add a reason explaining why calling setState inside this useEffect is intentional.
Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
| lastAnnouncementKeyRef.current = announcementKey; | ||
| const announcementText = translate('search.suggestionsAvailable', {count: flattenedSections.allOptions.length}); | ||
| if (Platform.OS === CONST.PLATFORM.WEB) { | ||
| // eslint-disable-next-line react-hooks/set-state-in-effect |
There was a problem hiding this comment.
❌ CONSISTENCY-5 (docs)
eslint-disable-next-line react-hooks/set-state-in-effect lacks an accompanying justification comment. Add a reason explaining why calling setState inside this useEffect is intentional.
Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
| const containerRef = useRef<View>(null); | ||
| const [suggestionsAnnouncement, setSuggestionsAnnouncement] = useState({id: 0, text: ''}); | ||
| const lastAnnouncementKeyRef = useRef(''); | ||
| const isMacOSChromeWeb = Platform.OS === CONST.PLATFORM.WEB && Browser.getBrowser() === CONST.BROWSER.CHROME && /Macintosh|Mac OS X/i.test(navigator.userAgent); |
There was a problem hiding this comment.
❌ CONSISTENCY-2 (docs)
The regex /Macintosh|Mac OS X/i is a magic value repeated in four files. Extract the macOS-Chrome detection into the Browser utility module (e.g. Browser.isMacOSChrome()) so every consumer shares a single, named constant and logic.
Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
|
|
||
| lastAnnouncementKeyRef.current = announcementKey; | ||
| const announcementText = translate('search.suggestionsAvailable'); | ||
| if (Platform.OS === CONST.PLATFORM.WEB) { |
There was a problem hiding this comment.
❌ CONSISTENCY-1 (docs)
Inline Platform.OS === CONST.PLATFORM.WEB checks are used to branch between web live-region rendering and native AccessibilityInfo.announceForAccessibility, and this pattern is repeated across four components. Extract the announcement behaviour into a custom hook with platform-specific file implementations (.web.ts / .native.ts) to remove the inline platform checks.
Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4eb0d39747
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!isFocused || !displayListViewBorder) { | ||
| lastAnnouncementKeyRef.current = ''; | ||
| return; |
There was a problem hiding this comment.
Gate suggestion announcement on real search results
This effect announces search.suggestionsAvailable as soon as displayListViewBorder is true, but that flag is layout-driven and can be true while the autocomplete list is still loading or transitioning between queries; in those cases users can hear “Suggestions available” even when there are no actionable suggestions yet (or none for the new query), which is misleading for screen-reader navigation. Please gate the announcement on an actual non-empty suggestion result state (or a verified non-loading result state) before updating the live region / calling announceForAccessibility.
Useful? React with 👍 / 👎.
|
@marufsharifi Could you check the failing pipeline and resolve the conflicts? |
| const containerRef = useRef<View>(null); | ||
| const [suggestionsAnnouncement, setSuggestionsAnnouncement] = useState({id: 0, text: ''}); | ||
| const lastAnnouncementKeyRef = useRef(''); | ||
| const isMacOSChromeWeb = Platform.OS === CONST.PLATFORM.WEB && getBrowser() === CONST.BROWSER.CHROME && /Macintosh|Mac OS X/i.test(navigator.userAgent); |
There was a problem hiding this comment.
Could you explain why we need specific isMacOSChromeWeb and how about on another browser?
I see that you added this in 4 places with the same condition. If this is really needed, should we move it to a utility function? and we should add unit tests for it
| suggestionsAvailable: ({count}: {count?: number} = {}) => { | ||
| const countText = count ? `${count} ${count === 1 ? 'Ergebnis' : 'Ergebnisse'}. ` : ''; | ||
| return `Vorschläge verfügbar. ${countText}Verwenden Sie die Pfeiltasten nach oben und unten zum Navigieren.`; | ||
| }, |
There was a problem hiding this comment.
Could you confirm the translation on Slack? Also, where does this translation come from?
Current message also different from expected result
When search suggestions appear, verify the screen reader announces the availability of suggestions and allows navigation through them. Example announcement: “Suggestions available. Use up and down arrow keys to navigate.”
| ref={containerRef} | ||
| fsClass={forwardedFSClass} | ||
| > | ||
| {Platform.OS === CONST.PLATFORM.WEB && !!suggestionsAnnouncement.text && ( |
There was a problem hiding this comment.
Please using getPlatform util to make consistent with another place
| key={suggestionsAnnouncement.id} | ||
| role={isMacOSChromeWeb ? CONST.ROLE.ALERT : CONST.ROLE.STATUS} | ||
| accessibilityLiveRegion={isMacOSChromeWeb ? 'assertive' : undefined} | ||
| style={isMacOSChromeWeb ? styles.screenReaderOnlyLiveRegion : styles.hiddenElementOutsideOfWindow} |
There was a problem hiding this comment.
Do we need to apply different hidden style for this one?
| // eslint-disable-next-line react-hooks/set-state-in-effect | ||
| setSuggestionsAnnouncement((prev) => { | ||
| const id = prev.id + 1; | ||
| const marker = isMacOSChromeWeb && id % 2 === 0 ? '\u2060' : ''; |
There was a problem hiding this comment.
What does it mean for u2060? please mention or create constant
|
@rushatgabhane, should i re-open this based on this comment? thanks. |
@marufsharifi I think you should create a separate PR for #77390 and not include the code changes for #74840. |
Explanation of Change
This change delivers a targeted accessibility improvement for web search/autocomplete flows: when suggestion results appear dynamically, screen readers are now notified via an off-screen live region
(role="status"), so users get immediate audible feedback instead of a silent visual-only update.Fixed Issues
$ #74840
PROPOSAL: #74840 (comment)
Tests
Offline tests
Same as Tests.
QA Steps
Same as Tests.
// TODO: These must be filled out, or the issue title must include "[No QA]."
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Screen.Recording.2026-02-26.at.3.41.45.PM.mov
Android: mWeb Chrome
Screen.Recording.2026-02-26.at.3.47.07.PM.mov
iOS: Native
Screen.Recording.2026-02-26.at.3.31.34.PM.mov
iOS: mWeb Safari
Screen.Recording.2026-02-26.at.4.01.06.PM.mov
MacOS: Chrome / Safari
Screen.Recording.2026-03-01.at.9.30.02.AM.mov