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

Enable gesture on navigator avoid to scroll horizontally on sub screen scrollview #10889

Open
4 of 12 tasks
TomCorvus opened this issue Sep 28, 2022 · 12 comments
Open
4 of 12 tasks

Comments

@TomCorvus
Copy link

Current behavior

On a sub screen, when I enable gestureEnabled on Navigator, I can't scroll on a horizontal ScrollView.

  • Swiping right to left does nothing
  • Swiping left to right on whole area ScrollView goes to the previous screen, but this same gesture don't do this on View, just only at the very left on the View (Normal)

This problem occurs only on Android.

Expected behavior

Get the same behavior of View.
Can scroll on horizontal ScrollView and go to the previous screen if I swipe to the very left of the screen.

Reproduction

https://github.com/TomCorvus/RNavigationScroll.git

Platform

  • Android
  • iOS
  • Web
  • Windows
  • MacOS

Packages

  • @react-navigation/​bottom-tabs
  • @react-navigation/​drawer
  • @react-navigation/​material-bottom-tabs
  • @react-navigation/​material-top-tabs
  • @react-navigation/​stack
  • @react-navigation/​native-stack

Environment

  • I've removed the packages that I don't use
package version
@react-navigation/native ^6.0.13
@react-navigation/material-top-tabs ^6.2.4
@react-navigation/stack ^6.3.1
react-native-safe-area-context ^4.4.1
react-native-screens ^3.17.0
react-native-gesture-handler ^2.6.2
react-native-tab-view ^3.1.1
react-native-pager-view ^6.0.0
react-native 0.70.1
node v16.16.0
npm or yarn 1.22.10
@Emptyuu
Copy link

Emptyuu commented Oct 1, 2022

I had the same problem

@oskargotte
Copy link

I had a similar problem. I fixed the scrolling by using another ScrollView -
import { ScrollView } from 'react-native-gesture-handler'
However, without any other actions, you'd lose the ability to navigate back by swiping left to right.

@fizhy37
Copy link

fizhy37 commented Nov 8, 2022

I have this same issue, but I'm using gestureDirection: 'vertical' and a FlatList instead of ScrollView. Also only happening on Android.

@vadamk
Copy link

vadamk commented Jan 23, 2023

It is really important for me

@TomCorvus
Copy link
Author

@vadamk did you try oskargotte solution?

Ashoat added a commit to CommE2E/comm that referenced this issue Jan 30, 2023
Summary:
This fixes [ENG-2845](https://linear.app/comm/issue/ENG-2845/cant-scroll-chatlist-on-android), which I introduced in D6331.

It looks like `gestureEnabled` breaks scrolling on Android. I found a [ton](react-navigation/react-navigation#10577 (comment)) of [GitHub](react-navigation/react-navigation#10889 (comment)) issues [discussing](software-mansion/react-native-gesture-handler#1775 (comment)) this, and the solution in all of them was to use `FlatList` from `react-native-gesture-handler`.

In this diff I went through every `FlatList` or `ScrollView` used in a `StackNavigator` where we have introduced `gestureEnabled` in D6331 (`Chat` and `Profile`), and I switched them to use `FlatList` from `react-native-gesture-handler`.

Test Plan:
1. First, I ran `git grep ScrollView` and `git grep FlatList` in `native/chat` and `native/profile` to try to find any examples of cases that needed to be changed
2. I deployed the app to a physical Android device to verify that scrolling still worked for all of the interfaces I fixed up

Reviewers: max, inka, tomek, bartek, przemek, kamil

Reviewed By: tomek

Subscribers: atul

Differential Revision: https://phab.comm.dev/D6417
@nikolal
Copy link

nikolal commented Apr 18, 2023

All StackNavigator modals suffer from this issue on Android.

  1. If gestureEnabled={true} --> Swiping down will close the modal but the ScrollView doesn't scroll.

  2. if gestureEnabled={false} --> ScrollView works but you cannot swipe down to close the modal.

  3. if import { ScrollView } from 'react-native-gesture-handler' --> ScrollView works but you cannot swipe down to close the modal even with gestureEnabled={true}. It seems that this import completely overwrites gestureEnabled prop.

I upgraded everything to latest versions:

  "react-native": "0.71.6",
  "@react-navigation/bottom-tabs": "^6.5.7",
  "@react-navigation/native": "^6.1.6",
  "@react-navigation/native-stack": "^6.9.12",
  "@react-navigation/stack": "^6.3.16",
  "react-native-screens": "^3.20.0",
  "react-native-safe-area-context": "^4.5.0",
  "react-native-gesture-handler": "^2.9.0",

@IcyHarka
Copy link

IcyHarka commented May 8, 2023

This worked for me:
import { ScrollView, FlatList } from 'react-native-gesture-handler'
After i used the scrollview / flatlist from 'react-native-gesture-handler' i had no problems with scrolls within the gestureEnabled={true}

SamSamskies added a commit to wavlake/mobile that referenced this issue Aug 31, 2023
not sure why, but the slider doesn't work when the screen has gestureDirection set to vertical. some other people have this problem with just scrolling horizontally in general react-navigation/react-navigation#10889.
SamSamskies added a commit to wavlake/mobile that referenced this issue Aug 31, 2023
* make full size music player full screen

* reduce size of artwork image

* animate album artwork on back and forward clicks

* prevent negative numbers

* fix song seeking

not sure why, but the slider doesn't work when the screen has gestureDirection set to vertical. some other people have this problem with just scrolling horizontally in general react-navigation/react-navigation#10889.

* prevent users from clicking buttons too fast

not the ideal solutions, but that's what the devs from expo-av suggest. expo/expo#11387
@jtvargas
Copy link

Any updates?

All StackNavigator modals suffer from this issue on Android.

  1. If gestureEnabled={true} --> Swiping down will close the modal but the ScrollView doesn't scroll.
  2. if gestureEnabled={false} --> ScrollView works but you cannot swipe down to close the modal.
  3. if import { ScrollView } from 'react-native-gesture-handler' --> ScrollView works but you cannot swipe down to close the modal even with gestureEnabled={true}. It seems that this import completely overwrites gestureEnabled prop.

I upgraded everything to latest versions:

  "react-native": "0.71.6",
  "@react-navigation/bottom-tabs": "^6.5.7",
  "@react-navigation/native": "^6.1.6",
  "@react-navigation/native-stack": "^6.9.12",
  "@react-navigation/stack": "^6.3.16",
  "react-native-screens": "^3.20.0",
  "react-native-safe-area-context": "^4.5.0",
  "react-native-gesture-handler": "^2.9.0",

I have the same issue

@JuEunSung
Copy link

JuEunSung commented Nov 27, 2023

I was facing the same problem

Apply the code below

The dependent module react-native-tab-view has been modified.

node_modules/react-native-tab-view/src/TabView.tsx

before
import { Pager } from './Pager';

after
import { PanResponderAdapter as Pager } from './PanResponderAdapter';

node_modules/react-native-tab-view/src/PanResponderAdapter.tsx

before
const DEAD_ZONE = 12;

after
const DEAD_ZONE = 100;

if necessary, use patch-package

@seba1342
Copy link

I have this same issue, but I'm using gestureDirection: 'vertical' and a FlatList instead of ScrollView. Also only happening on Android.

@fizhy37 I have found the following patch to somewhat fix this issue on Android:

diff --git a/node_modules/@react-navigation/stack/src/views/Stack/Card.tsx b/node_modules/@react-navigation/stack/src/views/Stack/Card.tsx
index 64a551e..70908f2 100755
--- a/node_modules/@react-navigation/stack/src/views/Stack/Card.tsx
+++ b/node_modules/@react-navigation/stack/src/views/Stack/Card.tsx
@@ -391,13 +391,15 @@ export default class Card extends React.Component<Props> {
 
     if (gestureDirection === 'vertical') {
       return {
+        activeOffsetY: Platform.OS === 'android' ? [-50, 50] : undefined,
         maxDeltaX: 15,
         minOffsetY: 5,
         hitSlop: { bottom: -layout.height + distance },
         enableTrackpadTwoFingerGesture,
-      };
+      }
     } else if (gestureDirection === 'vertical-inverted') {
       return {
+        activeOffsetY: Platform.OS === 'android' ? [-50, 50] : undefined,
         maxDeltaX: 15,
         minOffsetY: -5,
         hitSlop: { top: -layout.height + distance },

You can use patch-package to fix this

@bloggerklik
Copy link

Did you find a solution?

@talal-tilted
Copy link

Hello did someone find a solution ? I am use gestureEnabled: true with gestureDirection: 'vertical', I tried using ScrollView from gesture-handler also but not working even on ios

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests