Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
RootViewGestureHandler
handler cancel awaiting gestures (#2900)
## 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
- Loading branch information