Skip to content

Fix AccessibilityInfo.prefersCrossFadeTransitions unresolved promise#55920

Open
chicio wants to merge 1 commit intofacebook:mainfrom
chicio:accessibilityinfo_preferscrossfadetransitions_unresolved_promise
Open

Fix AccessibilityInfo.prefersCrossFadeTransitions unresolved promise#55920
chicio wants to merge 1 commit intofacebook:mainfrom
chicio:accessibilityinfo_preferscrossfadetransitions_unresolved_promise

Conversation

@chicio
Copy link
Contributor

@chicio chicio commented Mar 5, 2026

Summary:

This PR fixes a bug I found while exploring the codebase in the Components folder.

AccessibilityInfo exposes the method prefersCrossFadeTransitions. In the android branch, Promise.resolve(false) as return value was creating a new unrelated promise that never calls the resolve function provided by the promise executor constructor, so it was hangs indefinitely.

This means that if a user calls this method on android without any Platform.OS === ios guard, it will result in a unresolved promise.

I fixed the bug by aligning the implementation of prefersCrossFadeTransitions to the one of other methods (eg. isBoldTextEnabled).

I also added the tests to avoid regression, and additionally verify that the iOS method is doing what we are expecting (in both cases for when NativeAccessibilityManagerIOS.getCurrentPrefersCrossFadeTransitionsState is available or not).
The mock of the Platform object has been done the same way I saw while doing another contribution in the Pressability-test (see #55378 ).

I noticed the same bug in isHighTextContrastEnabled and isDarkerSystemColorsEnabled and I plan/would like to address them in follow-up PRs (and adding all the missing tests).

Changelog:

[ANDROID] [FIXED] - Fix AccessibilityInfo.prefersCrossFadeTransitions unresolved (never ending) promise

Test Plan:

This fix has been develop in TDD. I first added a failing test to reproduce that the android branch of the prefersCrossFadeTransitions method was acting as described above (resulting in failure due to jest timeout because the promise was not returning). Then I applied the fix, and finally added also the test for the iOS counterpart.

One final note: AccessibilityInfo is mocked globally in setup.js (via setupFiles in the Jest preset).
So to test the real implementation I had to use jest.unmock (pattern that I saw is already used in other component test files like View-test.js and TextInput-test.js).

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 5, 2026
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants