Skip to content

Fix AccessibilityInfo.isHighTextContrastEnabled unresolved promise#56066

Closed
chicio wants to merge 1 commit into
react:mainfrom
chicio:accessibilityinfo_ishightextcontrastenabled_unresolved_promise
Closed

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

Conversation

@chicio

@chicio chicio commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

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

meta-codesync Bot commented Mar 12, 2026

Copy link
Copy Markdown

@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
Copy Markdown
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

meta-codesync Bot commented Mar 12, 2026

Copy link
Copy Markdown

@vzaidman merged this pull request in 5c9a571.

meta-codesync Bot pushed a commit that referenced this pull request Apr 27, 2026
…gn null checks and error message code style (#56150)

Summary:
This PR continue the work I'm doing to improve the `AccessibilityInfo` module (#56066 and connected PRs).

In this new PR I added the missing tests for all the Promise based methods in the `AccessibilityInfo`, to prevent regressions similar to those fixed in the previous PRs.

This PR also includes a couple of small code style consistency improvement:
- aligned the null check in `getRecommendedTimeoutMillis` to the other ones already present in the file
- aligned the error messages returned from `isGrayscaleEnabled`, `isInvertColorsEnabled` and `isReduceMotionEnabled` to the other ones
- added the docs links where was missing (related to the PR I opened on the react-native doc repo)

## Changelog:

[GENERAL] [ADDED] - AccessibilityInfo: added missing tests for Promise based methods, align null checks and error message code style

Pull Request resolved: #56150

Test Plan: I run the tests that I added to verify their correctness. Some of them were failing because of the change of the error messages, and I made them green by changing the message in the production code. For this others, I verified their correctness by breaking the production code to see if they were failing.

Reviewed By: cipolleschi

Differential Revision: D102190403

Pulled By: cortinico

fbshipit-source-id: f5fe5cacfe0136b25a93d05f3b136c2bc49bd0e2
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