[Android] Fix onTouches* callbacks being called for all gestures#3596
Merged
[Android] Fix onTouches* callbacks being called for all gestures#3596
onTouches* callbacks being called for all gestures#3596Conversation
latekvo
approved these changes
Jul 4, 2025
MatiPl01
approved these changes
Jul 4, 2025
Member
MatiPl01
left a comment
There was a problem hiding this comment.
Works like a charm! I patched gesture handler in my lib and the issue is gone. Thanks for addressing the issue.
j-piasecki
reviewed
Jul 4, 2025
...andler/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt
Outdated
Show resolved
Hide resolved
j-piasecki
pushed a commit
that referenced
this pull request
Jul 7, 2025
…3596) ## Description Logic behind sending touch events on `android` dispatches events into all gesture handlers registered in the orchestrator. This means that interaction with one `GestureDetector` triggers callbacks on the others. This PR adds check for tracked pointer, so that handlers respond only to those that they are tracking. Fixes #3543 ## Test plan <details> <summary>Tested on the following example:</summary> ```jsx import React from 'react'; import { StyleSheet, Text, View } from 'react-native'; import { Gesture, GestureDetector, GestureHandlerRootView, } from 'react-native-gesture-handler'; type BoxProps = { label: string; }; function Box({ label }: BoxProps) { const manual = Gesture.Manual() .onTouchesDown((e) => { console.log('down', label, e.handlerTag); }) .onTouchesUp((e) => { console.log('up', label, e.handlerTag); }) .onTouchesCancelled(() => { console.log('cancelled', label); }); return ( <GestureDetector gesture={manual}> <View style={styles.box}> <Text style={styles.text}>{label}</Text> </View> </GestureDetector> ); } export default function EmptyExample() { return ( <GestureHandlerRootView style={styles.container}> <Box label="1" /> <Box label="2" /> </GestureHandlerRootView> ); } const styles = StyleSheet.create({ container: { flex: 1, alignItems: 'center', justifyContent: 'center', gap: 10, }, box: { width: 100, height: 100, backgroundColor: 'red', alignItems: 'center', justifyContent: 'center', }, text: { color: 'white', fontSize: 20, fontWeight: 'bold', }, }); ``` </details>
farfromrefug
added a commit
to nativescript-community/gesturehandler
that referenced
this pull request
Sep 5, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Logic behind sending touch events on
androiddispatches events into all gesture handlers registered in the orchestrator. This means that interaction with oneGestureDetectortriggers callbacks on the others. This PR adds check for tracked pointer, so that handlers respond only to those that they are tracking.Fixes #3543
Test plan
Tested on the following example: