Fix AccessibilityInfo.isDarkerSystemColorsEnabled unresolved promise#56019
Fix AccessibilityInfo.isDarkerSystemColorsEnabled unresolved promise#56019chicio wants to merge 5 commits intofacebook:mainfrom
Conversation
…accessibilityinfo_isdarkersystemcolorsenabled_unresolved_promise
…accessibilityinfo_isdarkersystemcolorsenabled_unresolved_promise
|
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. |
cortinico
left a comment
There was a problem hiding this comment.
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> { |
There was a problem hiding this comment.
I believe this API has the same bug you're fixing for isDarkerSystemColorsEnabled
Can we fix it in a separate PR?
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
Can you mockGetCurrentDarkerSystemColorsState.mockClear() here please?
There was a problem hiding this comment.
Sorry my bad 😞 and thanks for spotting this. Fixed in latest commit.
…accessibilityinfo_isdarkersystemcolorsenabled_unresolved_promise
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 |
|
@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 😢 |
|
Thanks @Simek for reopening it 🙏 😅 (and thank you for merging my other PR for the react native documentation) |
|
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? |
Summary:
This PR fixes a bug in the
AccessibilityInfocomponent. This is a follow up of the work I started with the PR I opened last week that has been already merged #55920.AccessibilityInfoexposes the methodisDarkerSystemColorsEnabled. 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
isDarkerSystemColorsEnabledto 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.getCurrentDarkerSystemColorsStateis 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
isDarkerSystemColorsEnabledmethod 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.