[Web] Reset NativeViewGestureHandler config on a full config replace - #4486
Conversation
## 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`.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 SummarySummary by CodeRabbit
WalkthroughChangesNative view configuration reset
Suggested reviewers: Merge Risk: ⚪ Minimal · up to 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)
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. Comment |
There was a problem hiding this comment.
🟢 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 = trueduringinit, allowing explicit config values to persist. - Add Jest tests validating default restoration and explicit
shouldCancelWhenOutsidebehavior 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.
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.