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 {