Skip to content

Gesture.Native cancelTouchesWhenOutside defaults to true on Android #4236

@mozzius

Description

@mozzius

Description

When a scrollable (ScrollView/FlatList) is wrapped in a GestureDetector with Gesture.Native() an in-progress scroll is cancelled on Android the moment the touch leaves the view's bounds. For a short horizontal row (e.g. a carousel), a normal horizontal swipe whose finger drifts slightly up or down exits the row's vertical bounds and the scroll cancels mid-gesture, leaving it "stuck." iOS behaves correctly (the scroll continues tracking the finger anywhere on screen, as expected once a gesture is active).

Root cause: NativeViewGestureHandler overrides the base default and sets shouldCancelWhenOutside = true (NativeViewGestureHandler.kt, init { shouldCancelWhenOutside = true };). With that flag, GestureHandler.kt cancels the handler when shouldCancelWhenOutside && !isWithinBounds. The base GestureHandler default is false, so this is specific to the native-view handler.

Steps to reproduce

  1. Use Gesture.Native() without additional configuration
  2. Wrap a ScrollView with it
  3. Observe it stops scrolling once the swipe leaves the bounds of the scrollview

A link to a Gist, an Expo Snack or a link to a repository based on this template that reproduces the bug.

https://snack.expo.dev/@mozzius/rngh-native-cancel-when-outside-bug

Gesture Handler version

2.28.0

React Native version

0.81.5

Platforms

Android

JavaScript runtime

Hermes

Workflow

Using Expo Prebuild or an Expo development build

Architecture

Old Architecture (Paper)

Build type

Debug mode

Device

Real device

Device model

Pixel 7a

Acknowledgements

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Platform: AndroidThis issue is specific to AndroidRepro providedA reproduction with a snack or repo is provided

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions