Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Text onPress triggers parent Touchable onPress #3159

Open
dragoncodes opened this issue Oct 15, 2024 · 1 comment
Open

[Android] Text onPress triggers parent Touchable onPress #3159

dragoncodes opened this issue Oct 15, 2024 · 1 comment
Labels
Platform: Android This issue is specific to Android Repro provided A reproduction with a snack or repo is provided

Comments

@dragoncodes
Copy link

Description

When a Text with onPress is a child of any Touchable (Opacity, Highlight, WithoutFeedback), when tapping on the Text the onPress of the Touchable parent is also triggered.

*Only seen on Android

Note: On iOS only the parent Touchable#onPress is triggered, but if the Text is wrapped in NativeViewGestureHandler -> only the Text#onPress is called

Steps to reproduce

  1. Open https://snack.expo.dev/@dragoncodes/rngh-multi-onpress-repro?platform=android
  2. Click on the text in the middle of the screen

Current behavior:

Counter is incremented by 2

Expected behaviour:

Counter is incremented by 1

Preview:

export default function App() {
  const [counter, setCounter] = useState(0);

  return (
    <GestureHandlerRootView
      style={{
        flex: 1,
        alignItems: 'center',
        justifyContent: 'center',
      }}>
      <Text>{`Counter: ${counter}`}</Text>

      <TouchableOpacity
        onPress={() => {
          setCounter(counter + 1);
        }}>
        <Text
          onPress={() => {
            setCounter(counter + 1);
          }}>
          {'Inner Text'}
        </Text>
      </TouchableOpacity>
    </GestureHandlerRootView>
  );
}

Note: Not sure what runtime snacks use, but also tested with react-native-gesture-handler@2.16.2, react-native@0.74.1, Hermes on a real device

Snack or a link to a repository

https://snack.expo.dev/@dragoncodes/rngh-multi-onpress-repro?platform=android

Gesture Handler version

2.16.2

React Native version

0.74.1

Platforms

Android

JavaScript runtime

Hermes

Workflow

Expo bare workflow

Architecture

Fabric (New Architecture)

Build type

Release mode

Device

Real device

Device model

Samsung Galaxy Fold 4

Acknowledgements

Yes

@github-actions github-actions bot added Platform: Android This issue is specific to Android Repro provided A reproduction with a snack or repo is provided labels Oct 15, 2024
@m-bert
Copy link
Contributor

m-bert commented Nov 8, 2024

Hi @dragoncodes! Could you please check if using our Text component from this PR works? 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Android This issue is specific to Android Repro provided A reproduction with a snack or repo is provided
Projects
None yet
Development

No branches or pull requests

2 participants