Skip to content

Fix Native gesture outside cancellation default#4239

Draft
sorinc03 wants to merge 1 commit into
software-mansion:mainfrom
sorinc03:fix/native-scroll-cancel-outside
Draft

Fix Native gesture outside cancellation default#4239
sorinc03 wants to merge 1 commit into
software-mansion:mainfrom
sorinc03:fix/native-scroll-cancel-outside

Conversation

@sorinc03
Copy link
Copy Markdown
Contributor

@sorinc03 sorinc03 commented Jun 5, 2026

Summary

Fixes #4236.

NativeViewGestureHandler on Android currently overrides the base handler default and sets shouldCancelWhenOutside to true. That causes Gesture.Native() wrappers around scrollable native views to fail once a swipe leaves the view bounds, even though the gesture is already active.

This PR restores the default to false, matching the documented base behavior for handlers other than Tap and LongPress, while preserving the explicit shouldCancelWhenOutside config path for callers that opt in.

Changes

  • Remove the redundant initializer that set shouldCancelWhenOutside = true.
  • Change NativeViewGestureHandler's Android default shouldCancelWhenOutside value to false.

Validation

  • yarn workspace react-native-gesture-handler format:android
  • yarn workspace react-native-gesture-handler lint:android
  • yarn workspace react-native-gesture-handler ts-check
  • yarn workspace react-native-gesture-handler test --runInBand
  • git diff --check

The local pre-commit hook also ran formatting, but then failed in apps/common-app on unrelated TypeScript setup issues (react-native-pager-view missing in a legacy sample). The targeted package checks above passed.

I did not run the Android Snack/device reproduction locally in this pass.

Copilot AI review requested due to automatic review settings June 5, 2026 10:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates NativeViewGestureHandler’s default cancel-outside behavior by removing an explicit initializer assignment and flipping the default constant.

Changes:

  • Removed the init block that forced shouldCancelWhenOutside = true.
  • Changed DEFAULT_SHOULD_CANCEL_WHEN_OUTSIDE from true to false.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 43 to 48

private var lastActiveUpdate: ActiveUpdateSnapshot? = null

init {
shouldCancelWhenOutside = true
}

override fun resetConfig() {
super.resetConfig()
shouldActivateOnStart = DEFAULT_SHOULD_ACTIVATE_ON_START
Comment on lines +225 to 227
private const val DEFAULT_SHOULD_CANCEL_WHEN_OUTSIDE = false
private const val DEFAULT_SHOULD_ACTIVATE_ON_START = false
private const val DEFAULT_DISALLOW_INTERRUPTION = false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gesture.Native cancelTouchesWhenOutside defaults to true on Android

2 participants