Reset enableTrackpadTwoFingerGesture in web PanGestureHandler - #4480
Conversation
`updateGestureConfig` writes `enableTrackpadTwoFingerGesture`, but `resetConfig` never restores it, so once a pan gesture has been configured with it, dropping the prop from a later config leaves two-finger trackpad panning enabled. iOS already clears the equivalent `allowedScrollTypesMask` in `RNPanHandler`'s `resetConfig`, so web was the odd one out. Adds a web test covering both the reset and the still-configured case.
|
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
WalkthroughChangesPan gesture configuration reset
Merge Risk: ⚪ Minimal · up to Web pan gestures now disable two-finger trackpad input when the option is removed while retaining it when explicitly enabled. The reset behavior is covered by tests and presents no remaining merge-blocking 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 fix is localized, matches existing config-reset patterns in the handler, and is backed by targeted regression tests that cover the reported failure mode.
Pull request overview
Fixes a web-only PanGestureHandler config-reset bug where enableTrackpadTwoFingerGesture could remain enabled after subsequent config updates omit the prop, causing stale two-finger trackpad wheel activation.
Changes:
- Reset
enableTrackpadTwoFingerGestureto its default (false) insidePanGestureHandler.resetConfig()on web. - Add Jest coverage to ensure the flag is correctly cleared when removed from later configs, and still works when present.
File summaries
| File | Description |
|---|---|
| packages/react-native-gesture-handler/src/web/handlers/PanGestureHandler.ts | Restores enableTrackpadTwoFingerGesture to default during resetConfig to prevent stale web wheel-gesture activation. |
| packages/react-native-gesture-handler/src/web/handlers/tests/PanGestureHandler.test.ts | Adds regression tests validating config replacement clears the flag and that the flag still enables touchpad wheel activation when set. |
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
On web,
PanGestureHandler.updateGestureConfigwritesenableTrackpadTwoFingerGesture, butresetConfignever restores it.setGestureConfigis a full config replace (resetConfigthenupdateGestureConfig), and it is whatupdateHandlers/useGesturecall whenever the gesture config changes. So once a pan gesture has been configured withenableTrackpadTwoFingerGesture: true, a later config that no longer carries the prop keeps two-finger trackpad panning enabled, and a wheel event from a trackpad still activates the gesture.Every other field the web
PanGestureHandlerreads from the config is restored inresetConfig; this one was missed. iOS is already correct:RNPanHandler'sresetConfigsetsrecognizer.allowedScrollTypesMask = 0, which is the same property. Android does not support the prop, so this is web only.Test plan
Added
src/web/handlers/__tests__/PanGestureHandler.test.tswith two cases:enableTrackpadTwoFingerGesture: true, then apply a config without it, and feed a touchpad wheel event: the handler must stayUNDETERMINED.enableTrackpadTwoFingerGesture: trueand feed the same event: the handler must reachACTIVE, so the flag itself keeps working.Without the one-line change in
resetConfig, the first test fails withExpected: 0 / Received: 4(the gesture activates from stale config). The second one passes both ways.yarn test,yarn lint-jsandyarn ts-checkare green inpackages/react-native-gesture-handler.