Commit 68d099a
authored
fix(Android): pressables lose focus on fast movement when
## Description
When `GestureHandler` & `GestureHandlerRootView` are present, the
pressables
in 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 the `EmptyGestureHandler`. In case you use e.g.
`Pan`, the movement does not have to 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`. Each `ScreenStack`
is since then
wrapped in a `GestureDetector`, which uses either
[`EmptyGestureHandler`](https://github.com/software-mansion/react-native-screens/blob/4d044dab8c387c6f3988434276594a2d917f5022/src/gesture-handler/ScreenGestureDetector.tsx#L27)
or [one defined based on gesture
config](https://github.com/software-mansion/react-native-screens/blob/4d044dab8c387c6f3988434276594a2d917f5022/src/gesture-handler/ScreenGestureDetector.tsx#L247).
### Issue mechanism
Basically it seems like bug in `gesture-handler`. The
`RNGestureHandlerRootHelper` [cancels
gesture](https://github.com/software-mansion/react-native-gesture-handler/blob/4232fc3127949c2869769542bfc7c3710b1348ee/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt#L87)
on 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, however
> testing it now it seems that the `Screen` is required (w/o `Screen` in
view hierarchy it seems to work fine...).
> Dunno what is going on 🤷
### Issue recording
https://github.com/user-attachments/assets/d0e9de2e-7d77-4379-b3f8-5da9e8b028ac
## 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` the `EmptyGestureHandler` we wrap
the `ScreenStack`.
> [!caution]
> **This is only partial workaround**. There still will be issue in case
someone setups the
`goBackGesture` & we pass `enabled` `GestureHandler` to
`GestureDetector`.
## Test code and steps to reproduce
`Test2819`, may require you to wrap `HomeOne` inside a `Screen`,
depending on the device/RN/other code mood I guess.
## Checklist
- [x] Included code example that can be used to test this change
- [ ] Ensured that CI passesgesture-handler is present (#2819)1 parent ef3cc02 commit 68d099a
3 files changed
Lines changed: 44 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| 129 | + | |
129 | 130 | | |
130 | 131 | | |
131 | 132 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
0 commit comments