Skip to content

Fix AccessibilityInfo.prefersCrossFadeTransitions unresolved promise#55920

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

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:

[GENERAL] [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
@chicio
Copy link
Contributor Author

chicio commented Mar 6, 2026

Hi @vzaidman, sorry to bother you. I see you were one of the last dev working on this piece of code (to improve the error description). Maybe you can help me to import this PR if the fix I made it makes sense? Thank you so much for your help 🙏.

Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this accessibility issue

@meta-codesync
Copy link

meta-codesync bot commented Mar 6, 2026

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this in D95565605.

@chicio
Copy link
Contributor Author

chicio commented Mar 6, 2026

Thanks for fixing this accessibility issue

Thank you for the review @cipolleschi!!! 🙏Tomorrow/in the next days I will open other PRs to fix the other problematic methods in AccessibilityInfo with the same problem (and I think also a part of the doc is not aligned, I will check how to update it).

Ps let me know if I have to do anything else before merging/to make this land in the main branch.

@meta-codesync meta-codesync bot closed this in 57c073f Mar 6, 2026
@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @chicio in 57c073f

When will my fix make it into a release? | How to file a pick request?

@react-native-bot react-native-bot added the Merged This PR has been merged. label Mar 6, 2026
@meta-codesync
Copy link

meta-codesync bot commented Mar 6, 2026

@cipolleschi merged this pull request in 57c073f.

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. Merged This PR has been merged. 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.

4 participants