From 580e7195806119162ccc04c3b064d0596a0024cf Mon Sep 17 00:00:00 2001 From: connorhanafee Date: Sun, 27 Mar 2022 22:50:41 +0100 Subject: [PATCH] fix: adding check for link length to prevent early return (#4982) Co-authored-by: Connor Hanafee Co-authored-by: dwelle --- src/components/App.tsx | 8 ++++---- src/element/Hyperlink.tsx | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index d3726714..7b9365cf 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -2409,13 +2409,13 @@ class App extends React.Component { } return ( element.link && + index <= hitElementIndex && isPointHittingLinkIcon( element, this.state, [scenePointer.x, scenePointer.y], this.deviceType.isMobile, - ) && - index <= hitElementIndex + ) ); }); }; @@ -2443,7 +2443,7 @@ class App extends React.Component { this.state, ); const lastPointerDownHittingLinkIcon = isPointHittingLinkIcon( - this.hitLinkElement!, + this.hitLinkElement, this.state, [lastPointerDownCoords.x, lastPointerDownCoords.y], this.deviceType.isMobile, @@ -2453,7 +2453,7 @@ class App extends React.Component { this.state, ); const lastPointerUpHittingLinkIcon = isPointHittingLinkIcon( - this.hitLinkElement!, + this.hitLinkElement, this.state, [lastPointerUpCoords.x, lastPointerUpCoords.y], this.deviceType.isMobile, diff --git a/src/element/Hyperlink.tsx b/src/element/Hyperlink.tsx index 7c2d5fbe..42a7a8f0 100644 --- a/src/element/Hyperlink.tsx +++ b/src/element/Hyperlink.tsx @@ -337,6 +337,9 @@ export const isPointHittingLinkIcon = ( [x, y]: Point, isMobile: boolean, ) => { + if (!element.link || appState.selectedElementIds[element.id]) { + return false; + } const threshold = 4 / appState.zoom.value; if ( !isMobile &&