Skip to content

Commit ccfb376

Browse files
giaBaoJSm-bert
authored andcommitted
Reset enableTrackpadTwoFingerGesture in web PanGestureHandler (#4480)
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. 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`.
1 parent f3ecd00 commit ccfb376

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

‎packages/react-native-gesture-handler/src/web/handlers/PanGestureHandler.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ export default class PanGestureHandler extends GestureHandler {
190190
this.maxPointers = DEFAULT_MAX_POINTERS;
191191

192192
this.activateAfterLongPress = 0;
193+
this.enableTrackpadTwoFingerGesture = false;
193194
}
194195

195196
protected transformNativeEvent() {

0 commit comments

Comments
 (0)