Skip to content

[Android] Touches up/down callbacks fired on multiple gesture detectors when should fire for only one #3543

@MatiPl01

Description

@MatiPl01

Description

I noticed that the onTouchesDown and onTouchesUp callback is being fired ona all currently touched gesture detectors when I start/stop touching just one of them but keep touching the other one.

The example, on which I tested it it works, is very simple and consists of just 2 boxes with gesture detectors:

Image

Example source code
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { Gesture, GestureDetector } from 'react-native-gesture-handler';

type BoxProps = {
  label: string;
};

function Box({ label }: BoxProps) {
  const manual = Gesture.Manual()
    .onTouchesDown(() => {
      console.log('down', label);
    })
    .onTouchesUp(() => {
      console.log('up', label);
    })
    .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 (
    <View style={styles.container}>
      <Box label="1" />
      <Box label="2" />
    </View>
  );
}

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',
  },
});

Android

Screen.Recording.2025-06-04.at.11.03.05.mp4

iOS

Screen.Recording.2025-06-04.at.11.05.12.mp4

Steps to reproduce

  1. I pressed the first box (with number 1) and didn't release the finger
  2. I was tapping on the second box (with number 2) - started and stopped pressing for a few times
  3. I finally released the finger from the first box (number 1)

A link to a Gist, an Expo Snack or a link to a repository based on this template that reproduces the bug.

https://snack.expo.dev/JaZCc4_vZlmyDOFHRlMEs

Gesture Handler version

2.25.0 (and older)

React Native version

0.80.0-rc.4 (and older)

Platforms

Android

JavaScript runtime

None

Workflow

None

Architecture

None

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions