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
5.95k stars 960 forks source link

```GestureDetector``` not working in android when used inside a nested TopTab from “@react-navigation/material-top-tabs” #2383

Closed hrithik73 closed 1 year ago

hrithik73 commented 1 year ago

Description

GestureDetector is not working when used inside a nested createMaterialTopTabNavigator from “@react-navigation/material-top-tabs” on android it works when there is only one tab not in nested also, work perfectly fine in ios

I have wrapped the root of my app with GestureHandlerRootView Note: - I have tried swipeEnabled: false in nested tab and wrapping the Rootview to different places in navigato

Steps to reproduce

step 1:- git clone https://github.com/hrithik73/rngh-toptab-issue.git step 2:- yarn step 3:- yarn android

Snack or a link to a repository

https://github.com/hrithik73/rngh-toptab-issue.git

Gesture Handler version

2.6.1

React Native version

0.70.1

Platforms

Android

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

Paper (Old Architecture)

Build type

Debug mode

Device

Android emulator

Device model

Pixel_4 (Android 12)

Acknowledgements

Yes

ttkien commented 1 year ago

I am facing the same issue that using Swipeable in the tab mentioned above cannot work on Android but work perfectly on iOS

j-piasecki commented 1 year ago

The PR above should enable you to fix the issue. Using it, you will be able to wrap each nested screen with <GestureHandlerRootView style={{flex: 1}} active>. This way, when the TopTab.Navigator tries to prevent its parent from handling touch, the child GH root view will handle it instead.

Keep in mind that you won't be able to define interactions (simultaneous, exclusive) between gestures attached under different root views.

@hrithik73 Can you try installing Gesture Handler from the aforementioned PR to check if it helps?

hrithik73 commented 1 year ago

Hi @j-piasecki , Sorry for the late response, I am new to OSS, can you please provide any reference/tutorial on how to install from a PR

@hrithik73 Can you try installing Gesture Handler from the aforementioned PR to check if it helps?

j-piasecki commented 1 year ago

@hrithik73 You could install it from the branch:

yarn add https://github.com/software-mansion/react-native-gesture-handler.git#@jpiasecki/root-view-always-active

Or from a specific commit:

yarn add https://github.com/software-mansion/react-native-gesture-handler.git#b9f236cfa180e8d42ca9d64c95db60c5c3aa327d

Alternatively, you can use patch-package, and generate the patch file by adding .diff suffix to the PR url, in this case it would be https://patch-diff.githubusercontent.com/raw/software-mansion/react-native-gesture-handler/pull/2401.diff.

javaing commented 2 weeks ago

The result of this specific commit is not resolve for me, as same as before 截屏2024-06-28 下午2 44 15

image