SIGN IN SIGN UP
facebook / react-native UNCLAIMED

A framework for building native applications using React

0 0 0 C++

Fix AccessibilityInfo.prefersCrossFadeTransitions unresolved promise (#55920)

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 https://github.com/facebook/react-native/issues/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

Pull Request resolved: https://github.com/facebook/react-native/pull/55920

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).

Reviewed By: vzaidman

Differential Revision: D95565605

Pulled By: cipolleschi

fbshipit-source-id: c666d198de593a79324801c181d571807d874bd5
F
Fabrizio Duroni committed
57c073f0d728575a43039e413ac5f0d6958e7e2f
Parent: 3057e28
Committed by meta-codesync[bot] <215208954+meta-codesync[bot]@users.noreply.github.com> on 3/6/2026, 9:52:33 PM