Skip to content

Fix AccessibilityInfo.isHighTextContrastEnabled unresolved promise#56066

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

Fix AccessibilityInfo.isHighTextContrastEnabled unresolved promise#56066
chicio wants to merge 1 commit intofacebook:mainfrom
chicio:accessibilityinfo_ishightextcontrastenabled_unresolved_promise

Conversation

@chicio
Copy link
Contributor

@chicio chicio commented Mar 11, 2026

Summary:

This PR fixes a bug in the AccessibilityInfo component. This is a follow up of the work I started with the PRs I opened in the last weeks #55920 #56019.

AccessibilityInfo exposes the method isHighTextContrastEnabled. In the else 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 hangs indefinitely (in the previous PRs the same bug affected the Android branch).

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

I fixed the bug in the same way as in the other PRs: by aligning the implementation of isHighTextContrastEnabled to the one of other methods.

I also added the tests to avoid regression, and additionally verify that the Android method is doing what we are expecting (in both cases for when NativeAccessibilityInfoAndroid.isHighTextContrastEnabled 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).

PS I will open one (or more if I see it is too big) PR to add the missing tests for the other `AccessibilityInfo methods still not tested.

Changelog:

[GENERAL] [FIXED] - Fix AccessibilityInfo.isHighTextContrastEnabled unresolved (never ending) promise

Test Plan:

This fix (as for the other PRs), was developed using TDD. I first added a failing test to reproduce that the iOS branch of the isHighTextContrastEnabled 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 Android counterpart.

@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 11, 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 12, 2026
@meta-codesync
Copy link

meta-codesync bot commented Mar 12, 2026

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

@meta-codesync meta-codesync bot closed this in 5c9a571 Mar 12, 2026
@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @chicio in 5c9a571

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 12, 2026
@meta-codesync
Copy link

meta-codesync bot commented Mar 12, 2026

@vzaidman merged this pull request in 5c9a571.

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.

3 participants