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
6.13k stars 982 forks source link

Fix Android native buttons emitting 2 press events when talkbalk is enabled #3002

Closed latekvo closed 4 months ago

latekvo commented 4 months ago

Description

When talkbalk accessability mode is enabled, pressing on any of the buttons provided by gesture handler (BaseButton, RawButton, BorderlessButton, Et Cetera) will cause 2 separate press events to go off.

This PR fixes that invalid behaviour.

Closes: #2808

Test plan

Attached example

import React from 'react';
import { BaseButton } from 'react-native-gesture-handler';
import { Text, View, StyleSheet } from 'react-native';

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

export default function App() {
  return (
    <View style={styles.root}>
      <BaseButton onPress={press}>
        <View
          accessible
          accessibilityRole="button"
          style={styles.button}
          onTouchStart={touch}>
          <Text>BaseButton</Text>
        </View>
      </BaseButton>
    </View>
  );
}

const styles = StyleSheet.create({
  root: {
    justifyContent: 'center',
    flex: 1,
  },
  button: {
    width: 200,
    height: 100,
    margin: 20,
    backgroundColor: 'cyan',
  },
});

Tests

Normal behaviour (no talkback, no fix):

image

Before fix:

image

With fix:

image

latekvo commented 4 months ago

Please ignore the linter issues for now, I'm working on getting openjdk running.