software-mansion / react-native-gesture-handler

Declarative API exposing platform native touch and gesture system to React Native.
https://docs.swmansion.com/react-native-gesture-handler/
MIT License
5.83k stars 952 forks source link

Android: touch events are executed twice when talkback is enabled #2808

Open IvanIhnatsiuk opened 1 month ago

IvanIhnatsiuk commented 1 month ago

Description

Hello, thanks for your library it is really good and very powerful 😎 .

I found an issue that when talkback is enabled, the onPress call occurs multiple times when interacting with the buttons.

https://github.com/software-mansion/react-native-gesture-handler/assets/86000012/8c37625f-75b7-4a8f-bce5-d20e29171b99

In the video the goBack callback was called twice, so I was navigated to the Accounts tab :)

Steps to reproduce

  1. Enable talkback on android emulator
  2. Run your example application on android emulator/real device
  3. Press on any button
  4. observe that onPress was executed twice

Snack or a link to a repository

https://github.com/software-mansion/react-native-gesture-handler

Gesture Handler version

2.15.0

React Native version

0.72.10

Platforms

Android

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

Paper (Old Architecture)

Build type

Debug mode

Device

Android emulator

Device model

Pixel 7 pro

Acknowledgements

Yes

github-actions[bot] commented 1 month ago

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

m-bert commented 1 month ago

Hi @IvanIhnatsiuk! I've just tested that on my Samsung S20+ and Pixel 6a emulator - both work fine. To test that, I've added logs into onPress callbacks in RectButtons. Could you provide a reproduction that we can look at?

IvanIhnatsiuk commented 1 month ago

@m-bert Hello, I think you can reproduce this in your example app. To reproduce this, I simply updated the App.tsx file to

import React from 'react';
import {
  BorderlessButton,
  GestureHandlerRootView,
} from 'react-native-gesture-handler';
import { Text } from 'react-native';

const press = () => console.log('pressed');

export default function App() {
  return (
    <GestureHandlerRootView style={{ justifyContent: 'center', flex: 1 }}>
      <BorderlessButton onPress={press}>
        <Text>Press me</Text>
      </BorderlessButton>
    </GestureHandlerRootView>
  );
}

https://github.com/software-mansion/react-native-gesture-handler/assets/86000012/e529c3f2-9861-4c69-a248-1300606cc831

Please, let me know if you need more details :)

m-bert commented 3 weeks ago

Hello @IvanIhnatsiuk! I've copied your code and everything is fine:

https://github.com/software-mansion/react-native-gesture-handler/assets/63123542/dabf65fe-29b7-41a2-a4c0-4b08580eccb5

It also works on my physical Samsung S20+

m-bert commented 3 weeks ago

I can see that you're using another emulator, I'll try to test that on Pixel 7

m-bert commented 3 weeks ago

Okay, I've tested that on Pixel 7 Pro emulator and I still wasn't able to reproduce this issue.