Skip to content

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

@TomCorvus

Description

@TomCorvus

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

Metadata

Metadata

Assignees

Labels

Platform: AndroidThis issue is specific to AndroidPlatform: iOSThis issue is specific to iOSRepro providedA reproduction with a snack or repo is provided

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions