fix: Math.floor animatedIndex value in BottomSheetBackdrop to fix And… #2342
+1
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
On some Android devices, with disabled animations, any screen with the component appears to "freeze". No component on the screen is able to be interacted with. The user cannot open the bottom sheet, click any buttons, or even scroll.
Steps to reproduce
backdropComponent
.Problem
The root of the issue appears to be the
useAnimatedReaction
hook in theBottomSheetBackdrop.tsx
component. The screen appears to "freeze" because although the backdrop is not visible, the backdrop logic is incorrectly disabling the touchability of the screen. On certain Android devices with reduced animations "on", the sharedValue ofanimatedIndex.value
only reaches the value of -0.999… and never crosses the threshold of -1 which is thedisappearsOnIndex
value. Thus, the return value on line 118 will always equal "false" and cause thehandleContainerTouchability
function to disable the pointerEvents and appear to "freeze" the screen.Solution
The proposed solution is to Math.floor() the
animatedIndex
sharedValue before comparing it to thedisappearsOnIndex
value. This will ensure that if the sharedValue does not quite reach thedisappearsOnIndex
value, it will not incorrectly disable touchability. In my app, I have this fixed as a local patch but am looking for a more long-term solution with this PR.Listed below are previous closed issues related to this fix:
#807
#1882
#527
#566