Skip to content

Fix AccessibilityInfo.isDarkerSystemColorsEnabled unresolved promise#56019

Closed
chicio wants to merge 5 commits intofacebook:mainfrom
chicio:accessibilityinfo_isdarkersystemcolorsenabled_unresolved_promise
Closed

Fix AccessibilityInfo.isDarkerSystemColorsEnabled unresolved promise#56019
chicio wants to merge 5 commits intofacebook:mainfrom
chicio:accessibilityinfo_isdarkersystemcolorsenabled_unresolved_promise

Conversation

@chicio
Copy link
Contributor

@chicio chicio commented Mar 9, 2026

Summary:

This PR fixes a bug in the AccessibilityInfo component. This is a follow up of the work I started with the PR I opened last week that has been already merged #55920.

AccessibilityInfo exposes the method isDarkerSystemColorsEnabled. 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 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 in the same way I fixed the one in the PR above: by aligning the implementation of isDarkerSystemColorsEnabled 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.getCurrentDarkerSystemColorsState 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 ).

Changelog:

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

Test Plan:

This fix, like the one in the previous PR, was develop using TDD. I first added a failing test to reproduce that the android branch of the isDarkerSystemColorsEnabled 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.

@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 9, 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 9, 2026
chicio added 2 commits March 9, 2026 22:55
…accessibilityinfo_isdarkersystemcolorsenabled_unresolved_promise
…accessibilityinfo_isdarkersystemcolorsenabled_unresolved_promise
@meta-codesync
Copy link

meta-codesync bot commented Mar 10, 2026

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

@vzaidman
Copy link
Contributor

Nice catch! Thank you.

@chicio
Copy link
Contributor Author

chicio commented Mar 10, 2026

Nice catch! Thank you.

Thank you for the review @vzaidman! 🙏 Let me know if I have to do anything else before merging/to make this land in the main branch.

Copy link
Contributor

@cortinico cortinico left a comment

Choose a reason for hiding this comment

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

Code looks generally good, but there is a nit in the tests that needs addressing

* Returns a promise which resolves to a boolean.
* The result is `true` when high text contrast is enabled and `false` otherwise.
*/
isHighTextContrastEnabled(): Promise<boolean> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this API has the same bug you're fixing for isDarkerSystemColorsEnabled

Can we fix it in a separate PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absolutely! I’m fixing these incrementally, one method per PR. The affected methods are prefersCrossFadeTransitions (fixed in the PR mentioned in the description), the one fixed in this PR, and the one you pointed out. I’ll open a separate PR for that as soon as this one is merged.

PS I'm also planning to add the missing tests for the other AccessibilityInfo methods, because the AccessibilityInfo-test was missing (I added it to demonstrate the bug and to avoid regression in the PR in the description).


beforeEach(() => {
originalPlatform = Platform.OS;
mockGetCurrentPrefersCrossFadeTransitionsState.mockClear();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you mockGetCurrentDarkerSystemColorsState.mockClear() here please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry my bad 😞 and thanks for spotting this. Fixed in latest commit.

@chicio
Copy link
Contributor Author

chicio commented Mar 10, 2026

Code looks generally good, but there is a nit in the tests that needs addressing

Thank you so much for the code review @cortinico 🙏 . I've addressed/answered to all the comments.

PS related to this, do you know to whom I can ask for a review on this facebook/react-native-website#5009? In this way we can fix also the documentation for some of the AccessibilityInfo methods (that are missing in the docs).

@chicio
Copy link
Contributor Author

chicio commented Mar 10, 2026

@cortinico The PR for the doc that I mentioned above got merged, and unfortunately it closed also this one, because I was referencing it 😅. Do you have the possibility to reopen it or should I open a new one? Thanks and sorry for the mess 😢

@Simek Simek reopened this Mar 10, 2026
@chicio
Copy link
Contributor Author

chicio commented Mar 10, 2026

Thanks @Simek for reopening it 🙏 😅 (and thank you for merging my other PR for the react native documentation)

@meta-codesync meta-codesync bot closed this in 8fbf2fa Mar 11, 2026
@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @chicio in 8fbf2fa

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 11, 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. 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.

6 participants