fix(Android): pressables lose focus on fast movement when gesture-handler
is present
#2819
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.
Description
When
GestureHandler
&GestureHandlerRootView
are present, the pressablesin subtree of
GestureHandler
will lose focus on fast initial movement.See the video below 👇.
Note
Edit: the fast movement requirement most likely comes from the fact that we use
fling
for theEmptyGestureHandler
. In case you use e.g.Pan
, the movement does not have to be fast.Note
The issue is reproducible w/o
react-native-screens
.The issue affects us, because #1913 added custom-screen-transitions based
on integration with
gesture-handler
&reanimated
. EachScreenStack
is since thenwrapped in a
GestureDetector
, which uses eitherEmptyGestureHandler
or one defined based on gesture config.
Issue mechanism
Basically it seems like bug in
gesture-handler
. TheRNGestureHandlerRootHelper
cancels gestureon the root view, causing RN pressable gesture handling to be cancelled. Instead, the attached gesture-handler
intercepts the touch events.
Warning
I was able to reproduce the issue 100% reliably earlier w/o presence of the
Screen
component, howevertesting it now it seems that the
Screen
is required (w/oScreen
in view hierarchy it seems to work fine...).Dunno what is going on 🤷
Issue recording
lose-focus-on-fast-swipe.mp4
Changes
It looks to me that it has to be handled on the side of
gesture-handler
/reac-native
core.Currently, I've decided to
disable
theEmptyGestureHandler
we wrap theScreenStack
.Caution
This is only partial workaround. There still will be issue in case someone setups the
goBackGesture
& we passenabled
GestureHandler
toGestureDetector
.Test code and steps to reproduce
Test2819
, may require you to wrapHomeOne
inside aScreen
, depending on the device/RN/other code mood I guess.Checklist