Skip to content

[Web] Reset NativeViewGestureHandler config on a full config replace - #4486

Open
j-piasecki wants to merge 1 commit into
mainfrom
push-psxlkolpnzon
Open

[Web] Reset NativeViewGestureHandler config on a full config replace#4486
j-piasecki wants to merge 1 commit into
mainfrom
push-psxlkolpnzon

Conversation

@j-piasecki

Copy link
Copy Markdown
Member

Description

The web NativeViewGestureHandler did not override resetConfig, so its props kept old values after setGestureConfig dropped them. It also forced shouldCancelWhenOutside to true in init, overriding an explicit false. The defaults now live in resetConfig, matching Android.

Test plan

Added tests in webNativeViewGestureHandler.test.ts.

## Description

The web NativeViewGestureHandler did not override resetConfig, so its props kept old values after setGestureConfig dropped them. It also forced shouldCancelWhenOutside to true in init, overriding an explicit false. The defaults now live in resetConfig, matching Android.

## Test plan

Added tests in `webNativeViewGestureHandler.test.ts`.
Copilot AI lite review requested due to automatic review settings September 7, 2026 06:11
@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 4a998544-fd08-4eef-98a3-aeb4aec64e84

📥 Commits

Reviewing files that changed from the base of the PR and between ebc923b and 8bac43c.

📒 Files selected for processing (2)
  • packages/react-native-gesture-handler/src/__tests__/webNativeViewGestureHandler.test.ts
  • packages/react-native-gesture-handler/src/web/handlers/NativeViewGestureHandler.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Gesture handlers now correctly restore default activation, interruption, cancellation, yielding, and long-press settings when configuration is reapplied.
    • Explicitly configured cancellation behavior remains preserved across initialization.
    • Gesture interactions now behave consistently when optional settings are omitted or reset.

Walkthrough

Changes

Native view configuration reset

Layer / File(s) Summary
Restore configuration defaults
packages/react-native-gesture-handler/src/web/handlers/NativeViewGestureHandler.ts
resetConfig restores configurable gesture state to its defaults. Initialization no longer resets shouldCancelWhenOutside.
Validate configuration reapplication
packages/react-native-gesture-handler/src/__tests__/webNativeViewGestureHandler.test.ts
The test helper accepts custom configuration. Tests verify default restoration for omitted fields and preservation of shouldCancelWhenOutside: false.

Suggested reviewers: m-bert

Merge Risk: ⚪ Minimal · up to 8bac4

Web native view gesture handlers now restore omitted options to their defaults when configuration is replaced while retaining explicit cancellation choices. The covered behavior is ready to merge with no identified current-head risk.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: resetting the NativeViewGestureHandler configuration when the full configuration is replaced.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The change correctly centralizes defaults in resetConfig() for full config replaces and includes targeted tests covering the reported regressions.

Pull request overview

This PR fixes web NativeViewGestureHandler so that a full config replacement (setGestureConfig) correctly restores web-specific defaults, aligning behavior with Android and preventing stale config values from persisting across replaces. It also stops init from overriding an explicit shouldCancelWhenOutside: false.

Changes:

  • Move web NativeViewGestureHandler defaults into an overridden resetConfig() so full config replaces restore defaults deterministically.
  • Stop forcing shouldCancelWhenOutside = true during init, allowing explicit config values to persist.
  • Add Jest tests validating default restoration and explicit shouldCancelWhenOutside behavior on web.
File summaries
File Description
packages/react-native-gesture-handler/src/web/handlers/NativeViewGestureHandler.ts Adds resetConfig() override to restore NativeView defaults on full config replace; removes init override of shouldCancelWhenOutside.
packages/react-native-gesture-handler/src/tests/webNativeViewGestureHandler.test.ts Adds regression tests covering full config replace default restoration and preserving explicit shouldCancelWhenOutside.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@m-bert m-bert left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Love the branch name

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.

3 participants