From b682d88167cf644f3ba93c54c6d017811f748ab8 Mon Sep 17 00:00:00 2001 From: David Luzar Date: Fri, 11 Mar 2022 15:45:59 +0100 Subject: [PATCH] fix: incorrectly erasing on mobile (#4899) * fix: incorrectly erasing on mobile * reintroduce fix for erasing on single-point click * fix snaps --- src/components/App.tsx | 16 +++++++++++++++- .../__snapshots__/regressionTests.test.tsx.snap | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 11ece6c4..9966bc69 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -2984,7 +2984,21 @@ class App extends React.Component { this.lastPointerUp = event; const isTouchScreen = ["pen", "touch"].includes(event.pointerType); - if (isTouchScreen || isEraserActive(this.state)) { + if (isTouchScreen) { + const scenePointer = viewportCoordsToSceneCoords( + { clientX: event.clientX, clientY: event.clientY }, + this.state, + ); + const hitElement = this.getElementAtPosition( + scenePointer.x, + scenePointer.y, + ); + this.hitLinkElement = this.getElementLinkAtPosition( + scenePointer, + hitElement, + ); + } + if (isEraserActive(this.state)) { const scenePointer = viewportCoordsToSceneCoords( { clientX: event.clientX, clientY: event.clientY }, this.state, diff --git a/src/tests/__snapshots__/regressionTests.test.tsx.snap b/src/tests/__snapshots__/regressionTests.test.tsx.snap index fc8f16e9..47cbed64 100644 --- a/src/tests/__snapshots__/regressionTests.test.tsx.snap +++ b/src/tests/__snapshots__/regressionTests.test.tsx.snap @@ -16860,7 +16860,7 @@ Object { exports[`regression tests two-finger scroll works: [end of test] number of elements 1`] = `0`; -exports[`regression tests two-finger scroll works: [end of test] number of renders 1`] = `16`; +exports[`regression tests two-finger scroll works: [end of test] number of renders 1`] = `12`; exports[`regression tests undo/redo drawing an element: [end of test] appState 1`] = ` Object {