Skip to content

Implement accessibility changes for search suggestions#85296

Merged
tylerkaraszewski merged 17 commits into
Expensify:mainfrom
ShridharGoel:accessibility77390
Mar 25, 2026
Merged

Implement accessibility changes for search suggestions#85296
tylerkaraszewski merged 17 commits into
Expensify:mainfrom
ShridharGoel:accessibility77390

Conversation

@ShridharGoel

@ShridharGoel ShridharGoel commented Mar 14, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

Implement accessibility changes for suggestions

Fixed Issues

$ #77390
PROPOSAL:

Tests

Precondition: User is logged in

  1. Using VoiceOver on iOS or TalkBack on Android, open the app
  2. Swipe right to focus the Account tab and double-tap to activate it
  3. Swipe right to focus the Profile button and double-tap to activate it
  4. Swipe right to focus the Status menu item and double-tap to activate it
  5. Swipe right to focus the Vacation delegate menu item and double-tap to activate it
  6. Note if the available list of suggestions is announced
  7. Swipe right to focus the text field and enter any search query
  8. After loading is complete, note if the search result suggestions are announced
  • Verify that no errors appear in the JS console

Offline tests

QA Steps

Same as tests.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Screen.Recording.2026-03-17.at.12.50.20.AM.mov
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari Screenshot 2026-03-17 at 1 24 54 AM

@melvin-bot

melvin-bot Bot commented Mar 14, 2026

Copy link
Copy Markdown

Hey, I noticed you changed src/languages/en.ts in a PR from a fork. For security reasons, translations are not generated automatically for PRs from forks.

If you want to automatically generate translations for other locales, an Expensify employee will have to:

  1. Look at the code and make sure there are no malicious changes.
  2. Run the Generate static translations GitHub workflow. If you have write access and the K2 extension, you can simply click: [this button]

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 --help

Typically, you'd want to translate only what you changed by running npx ts-node ./scripts/generateTranslations.ts --compare-ref main

@codecov

codecov Bot commented Mar 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
...ListWithSections/BaseSelectionListWithSections.tsx 93.90% <ø> (ø)
.../components/SelectionList/components/TextInput.tsx 100.00% <100.00%> (ø)
src/components/Search/SearchAutocompleteList.tsx 73.78% <70.00%> (+2.02%) ⬆️
src/hooks/useAccessibilityAnnouncement/index.ts 0.00% <0.00%> (ø)
... and 291 files with indirect coverage changes

@rushatgabhane

rushatgabhane commented Mar 14, 2026

Copy link
Copy Markdown
Member

@ShridharGoel can you borrow stuff from here - https://github.com/Expensify/App/pull/85166/changes

Feels like a lot of overlap in functions. Eg: the hook useAccessibilityAnnouncement

Wdyt? we'll resolve conflicts if they happen

@rushatgabhane

Copy link
Copy Markdown
Member

cc @Krishna2323 if you can advise us here

@rushatgabhane

Copy link
Copy Markdown
Member

@MelvinBot suggest changes #85296 (comment)

@MelvinBot

Copy link
Copy Markdown
Contributor

@rushatgabhane @ShridharGoel — Good catch, there is significant overlap between this PR and #85166. Here's a detailed breakdown and suggestions:

Overlap Summary

Both PRs implement accessibility announcements for screen readers, but they take different architectural approaches:

Concern PR #85166 (Krishna2323) PR #85296 (this PR)
Approach Reusable hook (useDebouncedAccessibilityAnnouncement) Component-based (SuggestionsAvailabilityAnnouncement + 3 platform helpers)
Debouncing useDebouncedValue hook + debounced announcement hook Manual timeout + lastAnnouncementRef dedup in component
Web announcement Enhances existing useAccessibilityAnnouncement (hidden aria-live div) Hidden <Text accessibilityLiveRegion="polite"> component
iOS announcement AccessibilityInfo.announceForAccessibility (via existing hook) AccessibilityInfo.announceForAccessibility (via platform helper)
Android announcement AccessibilityInfo.announceForAccessibility (via existing hook) Clear-then-set live region text with 50ms delay
"No results" announcements Yes (many pages: AddressSearch, EmojiPicker, SearchBar, TextInput, SelectionList, TableBody, WorkspaceWorkflows) No
"Suggestions available" announcements No Yes (SearchAutocompleteList, TextInput, BaseSelectionListWithSections)

Specific Suggestions

1. Reuse useDebouncedAccessibilityAnnouncement instead of SuggestionsAvailabilityAnnouncement

The new SuggestionsAvailabilityAnnouncement component (83 lines) + 3 platform helper files (37 lines) essentially reimplement what useDebouncedAccessibilityAnnouncement from #85166 already does. The hook approach is lighter and more composable:

// Instead of the SuggestionsAvailabilityAnnouncement component, you could do:
const suggestionsAnnouncement = suggestionsCount > 0
    ? translate('search.suggestionsAvailable', {count: suggestionsCount}, query)
    : '';
useDebouncedAccessibilityAnnouncement(suggestionsAnnouncement, suggestionsCount > 0, searchValue);

This would eliminate 4 new files:

  • SuggestionsAvailabilityAnnouncement.tsx
  • SuggestionsAvailabilityAnnouncementHelper.ts
  • SuggestionsAvailabilityAnnouncementHelper.android.ts
  • SuggestionsAvailabilityAnnouncementHelper.ios.ts

2. Coordinate on shared files

Both PRs modify these files and will conflict:

If this PR adopts the hook from #85166, the modifications to these files become additive rather than conflicting.

3. Keep what's unique to this PR

This PR does add value beyond #85166:

  • "Suggestions available" announcements — announcing the count of suggestions as the user types in search, which fix: Screen Readers: Many Pages: The status message of no results is not announced. #85166 doesn't cover
  • suggestionsAvailable translation key — the new localized string for suggestion count announcements
  • useMemo for sections in SearchAutocompleteList — performance improvement wrapping sections generation
  • dataLengthitemsCount fix in BaseSelectionListWithSections — corrects what gets passed to TextInput

4. Consider aria-hidden on visible text

PR #85166 adds aria-hidden to visible "no results" text elements to prevent screen readers from reading both the visible text AND the programmatic announcement. This PR should consider the same pattern for consistency, especially if the suggestions count is displayed visually anywhere.

Recommended Path Forward

  1. Wait for or coordinate with fix: Screen Readers: Many Pages: The status message of no results is not announced. #85166 to land first (it's more foundational — enhances core hooks used across many pages)
  2. Rebase this PR on top of it
  3. Replace the SuggestionsAvailabilityAnnouncement component with calls to useDebouncedAccessibilityAnnouncement
  4. Keep the unique parts: suggestionsAvailable translations, useMemo sections optimization, suggestion counting logic

This would significantly reduce the diff size and avoid maintaining two parallel announcement systems.

@ShridharGoel

Copy link
Copy Markdown
Contributor Author

@rushatgabhane So should we hold one till the other is done?

@rushatgabhane

rushatgabhane commented Mar 14, 2026

Copy link
Copy Markdown
Member

@ShridharGoel no we don't need to hold

You can use that PR as the base and build on top of it and sync it if there are changes

@rushatgabhane

Copy link
Copy Markdown
Member

or you can copy paste relevant stuff if that is simpler

@ShridharGoel ShridharGoel marked this pull request as ready for review March 16, 2026 19:58
@ShridharGoel ShridharGoel requested review from a team as code owners March 16, 2026 19:58
@melvin-bot melvin-bot Bot requested review from aimane-chnaif and removed request for a team March 16, 2026 19:58
@melvin-bot

melvin-bot Bot commented Mar 16, 2026

Copy link
Copy Markdown

@aimane-chnaif Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot melvin-bot Bot requested review from heyjennahay and removed request for a team March 16, 2026 19:58
@ShridharGoel

Copy link
Copy Markdown
Contributor Author

Will need help from someone with a physical iPhone to test on iOS.

@aimane-chnaif

Copy link
Copy Markdown
Contributor

Will need help from someone with a physical iPhone to test on iOS.

I have physical iPhone to test

return {sections: nextSections, styledRecentReports: nextStyledRecentReports};
}, [autocompleteQueryValue, autocompleteSuggestions, expensifyIcons, getAdditionalSections, recentReportsOptions, recentSearchesData, searchOptions, searchQueryItem, styles, translate]);

const sectionItemText = sections?.at(1)?.data?.[0]?.text ?? '';

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.

❌ CLEAN-REACT-PATTERNS-0 (docs)

React Compiler is enabled and will automatically memoize this pure computation. firstRecentReportFlatIndex is derived from firstRecentReportKey and sections with no side effects -- the compiler handles this without manual useMemo.

Remove the useMemo and compute the value directly:

let firstRecentReportFlatIndex = -1;
if (firstRecentReportKey) {
    let flatIndex = 0;
    for (const section of sections) {
        // ... existing iteration logic ...
    }
}

Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.

const timeout = setTimeout(() => {
setLiveRegionAnnouncement(announcement);
setAnnouncementTimeout(null);
}, 50);

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.

❌ CONSISTENCY-2 (docs)

The value 50 is a magic number used as a setTimeout delay for TalkBack live region updates. While the comment above explains the general strategy, the numeric value should be extracted into a named constant for readability and maintainability.

Extract it into a named constant:

const TALKBACK_LIVE_REGION_UPDATE_DELAY_MS = 50;

// Then use:
}, TALKBACK_LIVE_REGION_UPDATE_DELAY_MS);

Consider also adding it to CONST.TIMING if it may be reused elsewhere.


Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.

@aimane-chnaif

Copy link
Copy Markdown
Contributor

Please fix conflict

…ility77390

# Conflicts:
#	Mobile-Expensify
#	src/components/SelectionList/components/TextInput.tsx
#	src/components/SelectionListWithSections/BaseSelectionListWithSections.tsx
#	src/hooks/useAccessibilityAnnouncement/index.ts
#	src/hooks/useDebouncedAccessibilityAnnouncement.ts
#	src/hooks/useDebouncedValue.ts
@ShridharGoel

Copy link
Copy Markdown
Contributor Author

Just tried after pulling latest main. Can you check once by waiting a few seconds after the loading is complete before changing the query?

Screen.Recording.2026-03-20.at.2.56.52.AM.mov

@aimane-chnaif

Copy link
Copy Markdown
Contributor

Just tried after pulling latest main. Can you check once by waiting a few seconds after the loading is complete before changing the query?

Screen.Recording.2026-03-20.at.2.56.52.AM.mov

Still not working for me. Let's test in adhoc build

@melvin-bot

melvin-bot Bot commented Mar 19, 2026

Copy link
Copy Markdown

We did not find an internal engineer to review this PR, trying to assign a random engineer to #77390 as well as to this PR... Please reach out for help on Slack if no one gets assigned!

@melvin-bot melvin-bot Bot requested a review from tylerkaraszewski March 19, 2026 21:41
@github-actions

Copy link
Copy Markdown
Contributor

🚧 @mountiny has triggered a test Expensify/App build. You can view the workflow run here.

@github-actions

This comment has been minimized.

@aimane-chnaif

Copy link
Copy Markdown
Contributor

Just tested adhoc build. MacOS VoiceOver, Google Chrome
@ShridharGoel Still no announcement in search router, while works in reports search.

@ShridharGoel

Copy link
Copy Markdown
Contributor Author

Still working for me. Maybe we can get it QA tested.

Screen.Recording.2026-03-21.at.1.10.09.AM.mov

Comment thread src/components/SelectionList/components/TextInput.tsx Outdated
@rushatgabhane

Copy link
Copy Markdown
Member

@ShridharGoel bump

@aimane-chnaif

Copy link
Copy Markdown
Contributor

@rushatgabhane can we ask QA (or you) to test this page on MacOS VoiceOver?
I reproduced on my browser but not on @ShridharGoel's.
Otherwise looks good.

@rushatgabhane

Copy link
Copy Markdown
Member

yep on Chrome macos it doesn't workl

image

@aimane-chnaif

Copy link
Copy Markdown
Contributor

@ShridharGoel please pull main. Lint failing

@tylerkaraszewski tylerkaraszewski merged commit 96200e6 into Expensify:main Mar 25, 2026
32 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 @tylerkaraszewski has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/tylerkaraszewski in version: 9.3.49-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/grgia in version: 9.3.49-2 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants