Fix AccessibilityInfo.prefersCrossFadeTransitions unresolved promise#55920
Fix AccessibilityInfo.prefersCrossFadeTransitions unresolved promise#55920chicio wants to merge 1 commit intofacebook:mainfrom
Conversation
|
Hi @vzaidman, sorry to bother you. I see you were one of the last dev working on this piece of code (to improve the error description). Maybe you can help me to import this PR if the fix I made it makes sense? Thank you so much for your help 🙏. |
cipolleschi
left a comment
There was a problem hiding this comment.
Thanks for fixing this accessibility issue
|
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this in D95565605. |
Thank you for the review @cipolleschi!!! 🙏Tomorrow/in the next days I will open other PRs to fix the other problematic methods in Ps let me know if I have to do anything else before merging/to make this land in the main branch. |
|
This pull request was successfully merged by @chicio in 57c073f When will my fix make it into a release? | How to file a pick request? |
|
@cipolleschi merged this pull request in 57c073f. |
Summary:
This PR fixes a bug I found while exploring the codebase in the
Componentsfolder.AccessibilityInfoexposes the methodprefersCrossFadeTransitions. 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 === iosguard, it will result in a unresolved promise.I fixed the bug by aligning the implementation of
prefersCrossFadeTransitionsto 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.getCurrentPrefersCrossFadeTransitionsStateis available or not).The mock of the
Platformobject has been done the same way I saw while doing another contribution in thePressability-test(see #55378 ).I noticed the same bug in
isHighTextContrastEnabledandisDarkerSystemColorsEnabledand 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
Test Plan:
This fix has been develop in TDD. I first added a failing test to reproduce that the android branch of the
prefersCrossFadeTransitionsmethod 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:
AccessibilityInfois mocked globally insetup.js(viasetupFilesin 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).