From 9653d676fe15ff99028a83d8b3c80ba521d4e6bf Mon Sep 17 00:00:00 2001 From: David Luzar Date: Wed, 9 Feb 2022 20:42:02 +0100 Subject: [PATCH] fix: contextMenu timer & pointers not correctly reset on iOS (#4765) --- src/components/App.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index d9facb00..a0a15dba 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -1315,11 +1315,14 @@ class App extends React.Component { }; private onTapEnd = (event: TouchEvent) => { + this.resetContextMenuTimer(); if (event.touches.length > 0) { this.setState({ previousSelectedElementIds: {}, selectedElementIds: this.state.previousSelectedElementIds, }); + } else { + gesture.pointers.clear(); } }; @@ -1532,11 +1535,8 @@ class App extends React.Component { }; removePointer = (event: React.PointerEvent | PointerEvent) => { - // remove touch handler for context menu on touch devices - if (event.pointerType === "touch" && touchTimeout) { - clearTimeout(touchTimeout); - touchTimeout = 0; - invalidateContextMenu = false; + if (touchTimeout) { + this.resetContextMenuTimer(); } gesture.pointers.delete(event.pointerId); @@ -2937,6 +2937,12 @@ class App extends React.Component { } }; + private resetContextMenuTimer = () => { + clearTimeout(touchTimeout); + touchTimeout = 0; + invalidateContextMenu = false; + }; + private maybeCleanupAfterMissingPointerUp( event: React.PointerEvent, ): void {