From 00e30ca0e458341c58be7d641df5a3ad942aee87 Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Fri, 4 Feb 2022 20:36:21 +0530 Subject: [PATCH] fix: remove click listener for opening popup (#4700) * fix: remove click listener for oening popup * fix --- src/components/App.tsx | 16 ++++++++-------- src/element/Hyperlink.tsx | 1 - 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 979ad74c..5251482b 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -1520,6 +1520,14 @@ class App extends React.Component { removePointer = (event: React.PointerEvent | PointerEvent) => { this.lastPointerUp = event; + + if ( + this.hitLinkElement && + !this.state.selectedElementIds[this.hitLinkElement.id] + ) { + this.redirectToLink(); + } + // remove touch handler for context menu on touch devices if (event.pointerType === "touch" && touchTimeout) { clearTimeout(touchTimeout); @@ -2404,12 +2412,6 @@ class App extends React.Component { } } }; - private attachLinkListener = () => { - this.canvas?.addEventListener("click", this.redirectToLink); - }; - private detachLinkListener = () => { - this.canvas?.removeEventListener("click", this.redirectToLink); - }; private handleCanvasPointerMove = ( event: React.PointerEvent, @@ -2654,10 +2656,8 @@ class App extends React.Component { ) { setCursor(this.canvas, CURSOR_TYPE.POINTER); showHyperlinkTooltip(this.hitLinkElement, this.state); - this.attachLinkListener(); } else { hideHyperlinkToolip(); - this.detachLinkListener(); if ( hitElement && hitElement.link && diff --git a/src/element/Hyperlink.tsx b/src/element/Hyperlink.tsx index 884ef6ce..e653ba61 100644 --- a/src/element/Hyperlink.tsx +++ b/src/element/Hyperlink.tsx @@ -321,7 +321,6 @@ export const isPointHittingLinkIcon = ( x < linkX + threshold + linkWidth && y > linkY - threshold && y < linkY + linkHeight + threshold; - return hitLink; };