Skip to content

Add screen reader focus to emoji category shortcuts#84629

Merged
Beamanator merged 6 commits into
mainfrom
claude-emojiCategoryA11yFocus
Mar 19, 2026
Merged

Add screen reader focus to emoji category shortcuts#84629
Beamanator merged 6 commits into
mainfrom
claude-emojiCategoryA11yFocus

Conversation

@MelvinBot

Copy link
Copy Markdown
Contributor

Explanation of Change

When a screen reader user selects an emoji category shortcut button (e.g., "Frequently used", "Smileys"), the emoji list scrolls visually but no screen reader feedback is provided. This PR fixes the accessibility gap by:

  1. Making category headers accessible - Header View elements now have proper accessibility roles (header/heading) and labels so screen readers can identify them as section headings
  2. Moving screen reader focus to the selected header - After scrolling, focus is programmatically moved to the corresponding category heading. On native, this uses AccessibilityInfo.sendAccessibilityEvent; on web, .focus() via tabIndex={-1}
  3. Announcing the selected category - The active shortcut button now has accessibilityState={{ selected: true }} so screen readers announce the selected state

A retry mechanism handles the case where the target header may not be mounted yet in the virtualized FlashList when scrolling to a distant category.

Fixed Issues

$ #77490
PROPOSAL: #77490 (comment)

Tests

  1. Open the app and navigate to Profile > Status (or any screen with an emoji picker)
  2. Open the emoji picker
  3. Enable VoiceOver (iOS) or TalkBack (Android) or a screen reader on web
  4. Focus a category shortcut button (e.g., "Animals & Nature") and activate it
  5. Verify the screen reader announces the category heading (e.g., "Animals & Nature, heading")
  6. Verify screen reader focus moves to the category heading in the emoji list
  7. Verify the shortcut button announces "selected" state
  • Verify that no errors appear in the JS console

Offline tests

This change only affects UI accessibility rendering and screen reader focus management. No network requests are involved.

QA Steps

  1. Open the app on iOS with VoiceOver enabled (or Android with TalkBack)
  2. Navigate to Profile > Status > Status Emoji
  3. Swipe to focus a category shortcut button and double-tap to activate it
  4. Verify the screen reader announces the new category heading and focus moves to it
  5. Repeat with different categories, including ones far from the current scroll position
  6. Test the same flow from New Chat and Group Chat emoji pickers
  • 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
  • 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 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
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

When selecting an emoji category shortcut button, the screen reader now
receives proper feedback: the button announces its selected state, and
focus moves to the corresponding category heading in the emoji list.

Co-authored-by: truph01 <truph01@users.noreply.github.com>
@codecov

codecov Bot commented Mar 9, 2026

Copy link
Copy Markdown

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.

Files with missing lines Coverage Δ
src/components/EmojiPicker/CategoryShortcutBar.tsx 0.00% <0.00%> (ø)
...mojiPicker/EmojiPickerMenu/BaseEmojiPickerMenu.tsx 7.69% <0.00%> (-0.31%) ⬇️
.../components/EmojiPicker/CategoryShortcutButton.tsx 9.09% <0.00%> (-2.03%) ⬇️
...c/components/EmojiPicker/EmojiPickerMenu/index.tsx 0.00% <0.00%> (ø)
...nents/EmojiPicker/EmojiPickerMenu/index.native.tsx 0.00% <0.00%> (ø)
... and 13 files with indirect coverage changes

@MelvinBot

Copy link
Copy Markdown
Contributor Author

The failing checks are unrelated to this PR's changes.

Analysis: Both Android build failures (build (Debug, true) and build (developmentDebug, false)) are caused by Google's Maven repository (dl.google.com) returning 502 Bad Gateway errors when Gradle tried to download dependencies (e.g., camera-lifecycle, camera-view, play-services-mlkit-text-recognition, customview, databinding-compiler-common, asm-analysis, grpc-core, and 37+ others). This is a transient infrastructure issue on Google's side.

Evidence: This PR only modifies TypeScript/TSX emoji picker files (CategoryShortcutBar.tsx, CategoryShortcutButton.tsx, BaseEmojiPickerMenu.tsx, index.native.tsx, index.tsx). No Android build configuration, native code, or dependencies were changed. All other checks (ESLint, typecheck, tests, prettier, storybook, etc.) pass.

Re-running the failed builds should resolve this.

@truph01

truph01 commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

@MelvinBot Please merge main

…11yFocus

Co-authored-by: truph01 <truph01@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

Merged main into this branch.

}
pendingHeaderFocusIndexRef.current = null;
// eslint-disable-next-line @typescript-eslint/no-deprecated
InteractionManager.runAfterInteractions(() => {

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.

@MelvinBot
Why do we need InteractionManager.runAfterInteractions here? In the index.tsx version, we don’t use it.

Also, InteractionManager.runAfterInteractions is a deprecated method and should not be used in this app.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — removed InteractionManager.runAfterInteractions from both usages:

  1. focusHeaderAtIndex: Now calls AccessibilityInfo.sendAccessibilityEvent directly. The scheduleHeaderFocus retry mechanism (which retries up to 2 times with CONST.ANIMATED_TRANSITION delay) already handles the case where the ref isn't ready yet, so the InteractionManager wrapper was unnecessary.

  2. updateEmojiList: Now uses requestAnimationFrame directly without the InteractionManager wrapper, matching how the web version handles it.

Also removed the InteractionManager import since it's no longer used.

Replace with direct calls - AccessibilityInfo.sendAccessibilityEvent
is called directly in focusHeaderAtIndex (the scheduleHeaderFocus
retry mechanism already handles timing), and requestAnimationFrame
is used directly in updateEmojiList without the InteractionManager
wrapper.

Co-authored-by: truph01 <truph01@users.noreply.github.com>
Comment on lines +200 to +205
onMomentumScrollEnd={() => {
if (pendingHeaderFocusIndexRef.current == null) {
return;
}
scheduleHeaderFocus(pendingHeaderFocusIndexRef.current);
}}

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.

@MelvinBot In native version (index.native.tsx file), why do we need to call scheduleHeaderFocus in both onMomentumScrollEnd and scrollToHeader, meanwhile in web version (index.tsx file) we only call it in scrollToHeader?

@MelvinBot

Copy link
Copy Markdown
Contributor Author

The difference comes down to how scroll animations and FlashList virtualization behave on each platform.

On native, scrollToOffset({ animated: true }) triggers a native momentum scroll. With FlashList's virtualization, the target header may not be mounted yet when scrolling to a distant category. So there are two call sites as a fast path + fallback strategy:

  1. scrollToHeader (line 118) — the optimistic/fast path. It calls scheduleHeaderFocus immediately, which tries to focus right away and retries up to 2 times with CONST.ANIMATED_TRANSITION delays. If the header is nearby and already mounted, this succeeds quickly.

  2. onMomentumScrollEnd (line 200-205) — the safety net. If the header was too far away and wasn't mounted during those initial attempts, this catches it after the native scroll animation fully settles and the FlashList has rendered the target items. It checks pendingHeaderFocusIndexRef.current first — if the fast path already succeeded, focusHeaderAtIndex clears that ref to null (line 62), so onMomentumScrollEnd returns early and does nothing.

On web, the scroll animation is more predictable (CSS-based, no native momentum physics). The web version wraps scheduleHeaderFocus in a setTimeout(..., CONST.ANIMATED_TRANSITION) (line 287-289), which waits for the scroll animation to complete before attempting focus. Since web rendering is synchronous after the scroll completes, this single delayed call is reliable enough — there's no need for an onMomentumScrollEnd fallback.

In short: native needs both because the momentum scroll timing is unpredictable and virtualized items may not be mounted until the scroll fully settles. Web doesn't need the fallback because a simple setTimeout after the animation duration is sufficient.

@truph01

truph01 commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

@MelvinBot In scheduleHeaderFocus, the focus logic is wrapped in setTimeout with a CONST.ANIMATED_TRANSITION delay.

Then, in scrollToHeader, scheduleHeaderFocus is also wrapped in another setTimeout with the same CONST.ANIMATED_TRANSITION delay.

This approach looks like a workaround. Why do we need two setTimeout calls here, and why is the delay set to CONST.ANIMATED_TRANSITION? Additionally, setTimeout is generally discouraged in our app unless it is the only viable option. Could you clarify the reasoning behind this implementation?

@MelvinBot

Copy link
Copy Markdown
Contributor Author

Good question. The two setTimeout calls serve different purposes, but you're right that this is a workaround for a real limitation. Here's the breakdown:

1. The outer setTimeout in scrollToHeader (web only)

emojiListRef.current?.scrollToOffset({offset: calculatedOffset, animated: true});
setTimeout(() => {
    scheduleHeaderFocus(headerIndex);
}, CONST.ANIMATED_TRANSITION);

This waits for the animated scroll to finish before attempting to focus the header. scrollToOffset({animated: true}) doesn't provide a completion callback on web, and on web there's no reliable onMomentumScrollEnd event (which is why the native version uses onMomentumScrollEnd instead of this outer setTimeout). The 300ms value of CONST.ANIMATED_TRANSITION is used because it roughly matches the scroll animation duration — it's an existing constant already used elsewhere in the codebase for similar "wait for animation" patterns (e.g., useFocusAfterNav, useDelayedAutoFocus).

2. The inner setTimeout in scheduleHeaderFocus (retry mechanism)

function schedule(headerIndex, attempt = 0) {
    if (focusHeaderAtIndex(headerIndex)) return;
    if (attempt >= 2) return;
    setTimeout(() => schedule(headerIndex, attempt + 1), CONST.ANIMATED_TRANSITION);
}

Even after the scroll completes, FlashList's virtualization may not have rendered the target header yet (especially when scrolling to a distant category). If focusHeaderAtIndex finds the ref is null, it retries up to 2 more times. The handleHeaderLayout callback on each header View is the primary eager path — when a header mounts, it focuses immediately if it matches the pending index. The setTimeout retry is the fallback for when the header was already mounted (so onLayout won't fire again).

Why setTimeout and not an alternative?

This is admittedly a pragmatic workaround. The core problem is that FlashList doesn't provide a "scroll completed and target item is rendered" callback on web. The alternatives considered:

  • requestAnimationFrame polling loop — more complex, less readable, and still timing-dependent
  • InteractionManager.runAfterInteractions — deprecated (removed per your earlier feedback)
  • Listening for scroll events to detect when scrolling stops — unreliable on web, and still doesn't guarantee the target item is rendered

If there's a preferred pattern in the codebase for handling this kind of "wait for virtualized item to render after scroll" scenario, I'm happy to adopt it instead.

@truph01

truph01 commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

@MelvinBot Mark this PR as ready for review

@MelvinBot MelvinBot marked this pull request as ready for review March 11, 2026 07:03
@MelvinBot MelvinBot requested a review from a team as a code owner March 11, 2026 07:03
@MelvinBot

Copy link
Copy Markdown
Contributor Author

PR has been marked as ready for review.

@melvin-bot melvin-bot Bot requested review from heyjennahay and huult and removed request for a team March 11, 2026 07:03
@melvin-bot

melvin-bot Bot commented Mar 11, 2026

Copy link
Copy Markdown

@huult 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]

@truph01

truph01 commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

@huult Sorry, please ignore it. I will review it since I am working on #84310

@MelvinBot

Copy link
Copy Markdown
Contributor Author

The failing review check is unrelated to this PR's code changes.

Analysis: The review workflow failed during its setup phase — bun install received a transient HTTP 400 error from the npm registry when fetching universal-user-agent-6.0.1.tgz. This is an npm registry infrastructure issue, not a code problem.

Evidence: The error log shows:

error: GET https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.1.tgz - 400

This occurred before any code review logic ran. The other failing check (checklist) is the PR Author/Reviewer Checklist, which is unrelated to code.

Recommendation: Re-run the review check — it should pass on retry since this was a transient registry error.

@truph01

truph01 commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible 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 checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (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
    • 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 verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • 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
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • 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 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.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Screen.Recording.2026-03-13.at.10.10.17.mov
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-03-11.at.14.13.45.mov

@truph01

truph01 commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3226960b5c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +79 to +80
if (focusHeaderAtIndex(headerIndex)) {
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Ignore stale focus retries after newer category selection

schedule() always attempts focusHeaderAtIndex(headerIndex) even if another shortcut was selected afterward, so a delayed retry from an earlier tap can steal screen-reader focus back to the old category. This is reproducible when a user activates category A and then category B before A’s retry fires: the stale retry has no pendingHeaderFocusIndexRef guard and may announce the wrong heading.

Useful? React with 👍 / 👎.

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.

@MelvinBot Please check this comment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — this was a real bug. If a user quickly taps category A then category B, the delayed retry from A's scheduleHeaderFocus could fire after B was selected and steal screen-reader focus back to the wrong heading.

Fixed by adding a staleness guard at the top of scheduleHeaderFocus: it now checks pendingHeaderFocusIndexRef.current === headerIndex before each attempt. When a new category is selected, scrollToHeader updates pendingHeaderFocusIndexRef to the new index, so any in-flight retries for the old index will bail out immediately.

Applied to both index.tsx and index.native.tsx.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — added a staleness guard to scheduleHeaderFocus in both files. See my reply above for details.

Add a check at the top of scheduleHeaderFocus to bail out if
pendingHeaderFocusIndexRef no longer matches the target headerIndex.
This prevents a delayed retry from an earlier category tap from
stealing screen-reader focus after the user has already selected
a different category.

Co-authored-by: truph01 <truph01@users.noreply.github.com>
@truph01

This comment was marked as outdated.

@melvin-bot

melvin-bot Bot commented Mar 17, 2026

Copy link
Copy Markdown

We did not find an internal engineer to review this PR, trying to assign a random engineer to #77490 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 Beamanator March 17, 2026 18:17
@Beamanator

Copy link
Copy Markdown
Contributor

conflicts 😬

@truph01

truph01 commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

@MelvinBot We have conflicts, please resolve it.

Co-authored-by: truph01 <truph01@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

Merged main and resolved conflicts in BaseEmojiPickerMenu.tsx and index.native.tsx. Both files needed props/imports from both branches:

  • Kept onMomentumScrollEnd (accessibility focus feature) and searchValue (debounced search from main)
  • Kept AccessibilityInfo import (native a11y) and useMemo import (debounced filter from main)

@MelvinBot

Copy link
Copy Markdown
Contributor Author

The failing check (test (job 8)) is unrelated to this PR.

Analysis: The 2 failing tests are in tests/unit/canEditFieldOfMoneyRequestTest.ts ("should return true for submitter of a distance request for amount and currency fields" and "should return true for submitter when there are multiple outstanding reports"). These tests exercise canEditFieldOfMoneyRequest and ReportUtils.isReportOutstanding — completely unrelated to the emoji picker accessibility changes in this PR.

Evidence:

  • This PR only modifies emoji picker files: CategoryShortcutBar.tsx, CategoryShortcutButton.tsx, BaseEmojiPickerMenu.tsx, and EmojiPickerMenu/index.tsx/index.native.tsx
  • There is no diff between main and this branch for canEditFieldOfMoneyRequestTest.ts
  • The test passes locally when run in isolation — the failure is due to navigation state not being initialized (navigationRef.getCurrentRoute() at ReportUtils.ts:11484), which is a known flaky pattern in CI when tests share state
  • Re-running the CI job should resolve it

@truph01

truph01 commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

@Beamanator All good now! The test (job 8) isn't related to this PR.

@rushatgabhane

Copy link
Copy Markdown
Member

@MelvinBot merge main

…11yFocus

Co-authored-by: Rushat Gabhane <rushatgabhane@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

Merged main into this branch.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

The failing check build (developmentDebug, false) is unrelated to this PR's changes.

Analysis: The build fails with:

Could not read script '.../node_modules/expo/scripts/autolinking.gradle' as it does not exist.

This is an Android build infrastructure issue with expo autolinking — not related to the emoji picker accessibility changes in this PR.

Evidence: The same Build and deploy apps for testing workflow is also failing on the main branch (5 consecutive failures today: runs 23294927984, 23292979336, 23289478501, 23289471412, 23273137312) with the same build error. This PR only modifies TypeScript files in src/components/EmojiPicker/, which have no bearing on Android Gradle settings or expo autolinking configuration.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

The failing checks are unrelated to this PR's changes.

Failing checks:

  1. build (developmentDebug, false) — Android build fails with: Could not read script 'node_modules/expo/scripts/autolinking.gradle' as it does not exist
  2. build (New Expensify Dev, DebugDevelopment, false) — iOS build (appears to be a related infrastructure/CI issue)

Why these are unrelated:

  • This PR only modifies TypeScript/TSX files in src/components/EmojiPicker/ (accessibility improvements)
  • The same Android build failure is also occurring on main with the identical error — a missing expo autolinking gradle script
  • This is a CI infrastructure issue, not caused by any code changes in this PR

No action needed from the PR author. These builds should resolve once the infrastructure issue is fixed upstream.

@Beamanator

Copy link
Copy Markdown
Contributor

rerunning failing checks

@MelvinBot

Copy link
Copy Markdown
Contributor Author

The failing check build (developmentDebug, false) is unrelated to this PR.

Analysis: The build fails with Could not read script 'node_modules/expo/scripts/autolinking.gradle' as it does not exist at android/settings.gradle line 40. This is an Android build infrastructure issue with the Expo autolinking script missing from node_modules in the CI environment.

Evidence: The exact same error is occurring on the main branch (run 23307591253). This PR only modifies TypeScript files in the emoji picker (src/components/EmojiPicker/), which have no connection to the Android Gradle build configuration.

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

yeah i believe it, we can move forward

@Beamanator Beamanator merged commit e2277ac into main Mar 19, 2026
35 of 39 checks passed
@Beamanator Beamanator deleted the claude-emojiCategoryA11yFocus branch March 19, 2026 17:36
@Beamanator

Copy link
Copy Markdown
Contributor

failing checks unrelated

@melvin-bot melvin-bot Bot added the Emergency label Mar 19, 2026
@melvin-bot

melvin-bot Bot commented Mar 19, 2026

Copy link
Copy Markdown

@Beamanator looks like this was merged without a test passing. Please add a note explaining why this was done and remove the Emergency label if this is not an emergency.

@github-actions

Copy link
Copy Markdown
Contributor

🚧 @Beamanator 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/Beamanator in version: 9.3.41-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/cristipaval in version: 9.3.41-4 🚀

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.

7 participants