Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pan gesture always runs simultaneously with the PagerView #2870

Closed
j-piasecki opened this issue Apr 18, 2024 · 0 comments · Fixed by #2900
Closed

Pan gesture always runs simultaneously with the PagerView #2870

j-piasecki opened this issue Apr 18, 2024 · 0 comments · Fixed by #2900

Comments

@j-piasecki
Copy link
Member

Description

It looks like the pan gesture is not canceled when the RootViewGestureHandler activates, because it's already in the active state. I'm not sure whether it should be active at this point, or should be canceled despite being active.

Steps to reproduce

  1. When on the first page, the drawer never opens
  2. When on the second page, the drawer always opens simultaneously with the page switching to the first one

Snack or a link to a repository

https://github.com/lukmccall/ghandpager

Gesture Handler version

2.16.0

React Native version

0.73.6

Platforms

Android

JavaScript runtime

Hermes

Workflow

Expo bare workflow

Architecture

Paper (Old Architecture)

Build type

Debug mode

Device

Android emulator

Device model

No response

Acknowledgements

Yes

j-piasecki added a commit that referenced this issue May 9, 2024
## Description

Gesture Handler is handling calls to
`requestDisallowInterceptTouchEvent` by canceling all gestures:
https://github.com/software-mansion/react-native-gesture-handler/blob/5523506c7b64ac5a8a78f5d73dc96adfb13962ba/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt#L90-L94

This is done by activating a root handler that should, in turn, cancel
other gestures:
https://github.com/software-mansion/react-native-gesture-handler/blob/5523506c7b64ac5a8a78f5d73dc96adfb13962ba/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt#L109-L114

There is a case where this doesn't currently work: when gesture A waits
for gesture B and root view is activated, gesture B gets canceled but
gesture A is not due to this check:
https://github.com/software-mansion/react-native-gesture-handler/blob/5523506c7b64ac5a8a78f5d73dc96adfb13962ba/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt#L692-L698

Since handler A is awaiting, it doesn't get canceled. Gesture B does get
canceled, which in turn causes gesture A to activate, effectively making
it ignore the cancellation.

This happens because of this method:
https://github.com/software-mansion/react-native-gesture-handler/blob/5523506c7b64ac5a8a78f5d73dc96adfb13962ba/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.kt#L52-L58
which will always return false if the activating gesture is root view.

This PR makes it so that if the activating gesture is the root handler,
`shouldHandlerBeCancelledBy` will always return `true`, canceling the
waiting gesture.

Fixes
#2870

## Test plan

Tested on the example app and the reproducer from the issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant