Skip to content

Commit 5650e07

Browse files
j-piaseckiCopilot
andcommitted
Gate onPointerCancel
Co-authored-by: Copilot <copilot@github.com>
1 parent dba0388 commit 5650e07

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,9 @@ export default abstract class GestureHandler implements IGestureHandler {
362362
protected onPointerCancel(_event: AdaptedEvent): void {
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.
365-
this.cancel();
365+
if (GestureHandlerOrchestrator.instance.isHandlerRecorded(this)) {
366+
this.cancel();
367+
}
366368
}
367369
protected onPointerOutOfBounds(event: AdaptedEvent): void {
368370
this.tryToSendMoveEvent(true, event);

packages/react-native-gesture-handler/src/web/tools/GestureHandlerOrchestrator.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ export default class GestureHandlerOrchestrator {
3232
handler.activationIndex = Number.MAX_VALUE;
3333
}
3434

35+
public isHandlerRecorded(handler: IGestureHandler): boolean {
36+
return this.gestureHandlers.includes(handler);
37+
}
38+
3539
public removeHandlerFromOrchestrator(handler: IGestureHandler): void {
3640
const indexInGestureHandlers = this.gestureHandlers.indexOf(handler);
3741
const indexInAwaitingHandlers = this.awaitingHandlers.indexOf(handler);

0 commit comments

Comments
 (0)