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 nested buttons on the new architecture #2926

Closed j-piasecki closed 5 months ago

j-piasecki commented 5 months ago

Description

On the new architecture, due to composing RNGestureHandlerButton and RNGestureHandlerButtonComponentView the native view hierarchy wasn't representative of the hierarchy in the React Native. The most outer button would be rendered on top of all the react children, swallowing all the touches and preventing nested buttons from working.

This PR changes the behavior by mounting all children under the actual button view, which should result in the correct native hierarchy.

Test plan

Tested on the example app and on the following code: ```jsx import { SafeAreaView, View } from 'react-native'; import { GestureHandlerRootView, TouchableOpacity, } from 'react-native-gesture-handler'; export default function App() { return ( { console.log('outer press'); }}> { console.log('inner press'); }}> ); } ```