fix(components-native): Tie Toast a11y announcement to render lifecycle#3099
Draft
edison-cy-yang wants to merge 1 commit into
Draft
fix(components-native): Tie Toast a11y announcement to render lifecycle#3099edison-cy-yang wants to merge 1 commit into
edison-cy-yang wants to merge 1 commit into
Conversation
Deploying atlantis with
|
| Latest commit: |
1572823
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8d48eea4.atlantis.pages.dev |
| Branch Preview URL: | https://edi-fix-toast-test-flake.atlantis.pages.dev |
|
Published Pre-release for 1572823 with versions: To install the new version(s) for Mobile run: |
Contributor
Author
|
I tested this change on device and somehow the voiceover isn't working |
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.
Why Is This Changing?
AccessibilityInfo.announceForAccessibilitywas being called inside theonShowanimation callback of
react-native-toast-message, behind a 100mssetTimeout.This created a two-step async chain (animation callback → timer) that was
unreliable under CI load, causing intermittent failures:
Error: expect(jest.fn()).toHaveBeenCalledWith(...expected)
Expected: "Notify message"
Number of calls: 0
The root cause:
onShowis called synchronously before React flushes thesetIsVisible(true)state update, so the timer is scheduled at an earlier,less predictable point relative to the test's
waitForpolling window. Onslower CI machines, the timer races against
waitFor's timeout.What Is Changing?
Toast.tsx: MovesannounceForAccessibilityfromshowToast'sonShowcallback into a
useEffectinsideDefaultToast. The component mounting isthe correct signal that the toast is visible — no animation callback required.
The 100ms delay is preserved to avoid conflicting with the entrance animation
on device.
Consumer Impact
Validation
onShowfromToast.showto simulate the racecondition. It would fail on the original code (
Number of calls: 0) and passeswith the fix. It is not included in the diff since it was only used to confirm the root cause of the flake.
Reviewer Notes
The key insight is that tying the announcement to
useEffect(React's renderlifecycle) rather than an animation callback makes RNTL's
waitFor/findByTextthe right tool — both respond to the same render flush, so there's no longer a
hidden async dependency that the test framework can't see.
Changes can be
tested via Pre-release
In Atlantis we use Github's built in pull request reviews.