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

GestureDetector blocking ScrollView in Mobile Web (even if explicitly disabled) #3010

Closed
mikehobi opened this issue Jul 26, 2024 · 3 comments
Labels
Close when stale The issue will be closed automatically if it remains inactive Platform: Web Repro provided A reproduction with a snack or repo is provided

Comments

@mikehobi
Copy link

Description

I'm trying to create a scrolling feed with a draggable/swipable elements.

When I include GestureDetector inside a ScrollView, scrolling is disabled altogether. I'm trying to implement a solution that allows vertical scrolling and horizontal swiping (on the draggable elements)

The solutions appear to work for iOS/Android, but not for mobile web.

I've provided a simple repro'd snack demo.

Steps to reproduce

  1. Implement GestureRoot, ScrollView, and Gesture components
  2. Add Gesture.Pan, set to enabled(false) or manualActivation
  3. See that scrolling is blocked on Safari (or when emulating mobile device in Chrome Devtools)

Snack or a link to a repository

https://snack.expo.dev/@mikehobi/awkward-red-cereal?platform=web

Gesture Handler version

2.16.1

React Native version

0.74.3

Platforms

Web

JavaScript runtime

None

Workflow

Expo bare workflow

Architecture

None

Build type

None

Device

Real device

Device model

iPhone Latest

Acknowledgements

Yes

@github-actions github-actions bot added Repro provided A reproduction with a snack or repo is provided Platform: Web labels Jul 26, 2024
@m-bert
Copy link
Contributor

m-bert commented Jul 29, 2024

Hi @mikehobi! This issue seems closely related to #2617. You can try to add touchAction property to GestureDetector and set it to pan-y. This is already done internally in our Swipeable implementation. Let me know if it helps!

@m-bert m-bert added the Close when stale The issue will be closed automatically if it remains inactive label Aug 1, 2024
@mikehobi
Copy link
Author

mikehobi commented Aug 7, 2024

Thanks, touch-action does indeed solve my issue.

I guess I am still curious why .enabled(false) still captures events though, seems as though if it's disabled completely, it should not block other events.

Closing!

@mikehobi mikehobi closed this as completed Aug 7, 2024
@m-bert
Copy link
Contributor

m-bert commented Aug 8, 2024

I guess I am still curious why .enabled(false) still captures events though, seems as though if it's disabled completely, it should not block other events.

When handler is created, it sets touch-action: none; on underlying view by default. Currently there's no logic that checks if handler is enabled or not, so changing this property won't change touch-action.

Do you think it should be added?

m-bert added a commit that referenced this issue Aug 12, 2024
## Description

As mentioned in [this comment](#3010 (comment)), it may be confusing that Gesture Handler blocks default events even if it is explicitly disabled. This PR adds styles reset when `enabled` property changes.

Currently it changes 3 things:

1. Changes `touch-action` to default value
2. Changes `user-select` to default value
3. Re-enables context menu usage.

I'm not sure if I missed something. If so, please mention it in a comment.

## Test plan

Tested on newly added example.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Close when stale The issue will be closed automatically if it remains inactive Platform: Web Repro provided A reproduction with a snack or repo is provided
Projects
None yet
Development

No branches or pull requests

2 participants