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

onPress action on Pressable component inside another triggers both actions #3282

Open
TomCorvus opened this issue Dec 11, 2024 · 5 comments · May be fixed by #3295
Open

onPress action on Pressable component inside another triggers both actions #3282

TomCorvus opened this issue Dec 11, 2024 · 5 comments · May be fixed by #3295
Assignees
Labels
Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snack or repo is provided

Comments

@TomCorvus
Copy link

TomCorvus commented Dec 11, 2024

Description

Hello,

I have some Pressable components inside another, and when I click on child one, it's triggered parent onPress action.
It occurs on real and simulator devices on Android and iOS.

Switch with Pressable component from react-native and the child onPress action doesn't trigger the parent onPress action.

I tried others pressable components like TouchableOpacity and here the results when I click on child pressable component:
TouchableHighlight in TouchableOpacity -> both trigered
TouchableOpacity in TouchableHighlight -> parent action trigered
TouchableOpacity in TouchableOpacity -> child action trigered
TouchableHighlight in TouchableHighlight -> child action trigered
Pressable in TouchableHighlight -> child action trigered
Pressable in TouchableOpacity -> both trigered
Pressable in Pressable -> both trigered
TouchableHighlight in Pressable -> both trigered
TouchableOpacity in Pressable -> parent action trigered
TextInput in Pressable -> parent action trigered (only on Android)

Steps to reproduce

  1. Clone repo
  2. react-native start
  3. Click on button on the first tab
  4. Check console logs

Snack or a link to a repository

https://github.com/TomCorvus/RNavigation

Gesture Handler version

2.21.2

React Native version

0.76.3

Platforms

Android, iOS

JavaScript runtime

Hermes

Workflow

Expo bare workflow

Architecture

Fabric (New Architecture)

Build type

Debug mode

Device

iOS simulator

Device model

Pixel 7 Pro, iPhone 16 Pro

Acknowledgements

Yes

@github-actions github-actions bot added Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snack or repo is provided labels Dec 11, 2024
@TomCorvus
Copy link
Author

I can add TextInput in Pressable. When I focus the TextInput, it's trigered the onPress action of Pressable component.
It's seems to occur only on Android. Not on iOS.

@TomCorvus
Copy link
Author

I tried your fix, but it seems to not fix the TextInput inside Pressable.

@coado
Copy link
Contributor

coado commented Dec 17, 2024

I tried your fix, but it seems to not fix the TextInput inside Pressable.

Previous PR fixed different issue. Could you check if #3295 solves this one for you?

@TomCorvus
Copy link
Author

Great @coado, it seems to fix the problem. Do you know when a new version including all theses fixes will be released?

@coado
Copy link
Contributor

coado commented Dec 19, 2024

Great @coado, it seems to fix the problem. Do you know when a new version including all theses fixes will be released?

The stable version will be released around 10th January 2025 probably. The PR is not fully ready to be merged though as it still doesn't work on the old arch :/

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 Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snack or repo is provided
Projects
None yet
2 participants