Skip to content

Commit 9c6f72c

Browse files
authored
[Web] Remove explicit reset from onPointerCancel (#4133)
## Description #4128 changed how handlers kept in the orchestrator are treated - those can now influence other handlers' state. When trying to use the `Touchable` component in the example app, I've noticed that other buttons become unresponsive after scrolling cancels the pressed button. This turned out to be caused by an explicit `reset` call inside `onPointerCancel`. This caused the handler's state to go to `UNDETERMINED` between the change to `CANCELED` and the time the orchestrator runs `cleanupFinishedHandlers`. When the orchestrator goes over the handlers to clean, it ignores handlers that are not in a finished state. Since the gesture changed to `UNDETERMINED`, it was kept in the orchestrator after being canceled. Note that the handler is still being reset by the orchestrator in a scheduled microtask. ## Test plan I replaced `RectButtons` on in the example app list with `Touchables` |Before|After| |-|-| |<video src="https://github.com/user-attachments/assets/84f64388-9cac-4ac5-bc05-afc03007178e" />|<video src="https://github.com/user-attachments/assets/262d0215-3360-42a7-bb53-02ec1b8488ab" />|
1 parent 5460083 commit 9c6f72c

2 files changed

Lines changed: 0 additions & 6 deletions

File tree

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,6 @@ export default abstract class GestureHandler implements IGestureHandler {
363363
// No need to send a cancel touch event explicitly here. `cancel` will
364364
// handle cancelling all tracked touches if the handler expects pointer data.
365365
this.cancel();
366-
this.reset();
367366
}
368367
protected onPointerOutOfBounds(event: AdaptedEvent): void {
369368
this.tryToSendMoveEvent(true, event);

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,4 @@ export default class HoverGestureHandler extends GestureHandler {
5252

5353
super.onPointerMove(event);
5454
}
55-
56-
protected override onPointerCancel(event: AdaptedEvent): void {
57-
super.onPointerCancel(event);
58-
this.reset();
59-
}
6055
}

0 commit comments

Comments
 (0)