Skip to content

Reset enableTrackpadTwoFingerGesture in web PanGestureHandler - #4480

Merged
j-piasecki merged 1 commit into
software-mansion:mainfrom
giaBaoJS:web-pan-reset-trackpad-two-finger
Sep 4, 2026
Merged

Reset enableTrackpadTwoFingerGesture in web PanGestureHandler#4480
j-piasecki merged 1 commit into
software-mansion:mainfrom
giaBaoJS:web-pan-reset-trackpad-two-finger

Conversation

@giaBaoJS

@giaBaoJS giaBaoJS commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Description

On web, PanGestureHandler.updateGestureConfig writes enableTrackpadTwoFingerGesture, but resetConfig never restores it.

setGestureConfig is a full config replace (resetConfig then updateGestureConfig), and it is what updateHandlers / useGesture call whenever the gesture config changes. So once a pan gesture has been configured with enableTrackpadTwoFingerGesture: 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 PanGestureHandler reads from the config is restored in resetConfig; this one was missed. iOS is already correct: RNPanHandler's resetConfig sets recognizer.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.ts with two cases:

  • configure the handler with enableTrackpadTwoFingerGesture: true, then apply a config without it, and feed a touchpad wheel event: the handler must stay UNDETERMINED.
  • configure it with enableTrackpadTwoFingerGesture: true and feed the same event: the handler must reach ACTIVE, so the flag itself keeps working.

Without the one-line change in resetConfig, the first test fails with Expected: 0 / Received: 4 (the gesture activates from stale config). The second one passes both ways.

yarn test, yarn lint-js and yarn ts-check are green in packages/react-native-gesture-handler.

`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.
Copilot AI lite review requested due to automatic review settings September 4, 2026 07:31
@coderabbitai

coderabbitai Bot commented Sep 4, 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: 02041c7b-80ae-4ee7-8ec5-6eb0e772326c

📥 Commits

Reviewing files that changed from the base of the PR and between 6f45895 and ac32efa.

📒 Files selected for processing (2)
  • packages/react-native-gesture-handler/src/web/handlers/PanGestureHandler.ts
  • packages/react-native-gesture-handler/src/web/handlers/__tests__/PanGestureHandler.test.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

    • Resetting pan gesture configuration now correctly disables two-finger trackpad gestures when the option is omitted.
    • Explicitly enabled trackpad two-finger gestures continue to work after configuration updates.
  • Tests

    • Added coverage for restoring the default disabled state and preserving explicitly enabled behavior.

Walkthrough

Changes

Pan gesture configuration reset

Layer / File(s) Summary
Reset trackpad gesture configuration
packages/react-native-gesture-handler/src/web/handlers/PanGestureHandler.ts, packages/react-native-gesture-handler/src/web/handlers/__tests__/PanGestureHandler.test.ts
resetConfig now disables enableTrackpadTwoFingerGesture by default. Tests verify both the disabled default and the explicitly enabled configuration.
Suggested reviewers: m-bert

Merge Risk: ⚪ Minimal · up to ac32e

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)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: resetting enableTrackpadTwoFingerGesture in the web PanGestureHandler.
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.

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 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 enableTrackpadTwoFingerGesture to its default (false) inside PanGestureHandler.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.

@j-piasecki j-piasecki left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@j-piasecki
j-piasecki merged commit 5eaf877 into software-mansion:main Sep 4, 2026
7 of 8 checks passed
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