From 92ffe8dda65adb6ed1eaba3faa9db53d1b80d400 Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Wed, 9 Feb 2022 16:33:49 +0530 Subject: [PATCH] fix: use absolute coords when rendering link popover (#4753) --- src/element/Hyperlink.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/element/Hyperlink.tsx b/src/element/Hyperlink.tsx index fa0ca8df..02e6a45c 100644 --- a/src/element/Hyperlink.tsx +++ b/src/element/Hyperlink.tsx @@ -212,8 +212,9 @@ const getCoordsForPopover = ( element: NonDeletedExcalidrawElement, appState: AppState, ) => { + const [x1, y1] = getElementAbsoluteCoords(element); const { x: viewportX, y: viewportY } = sceneCoordsToViewportCoords( - { sceneX: element.x + element.width / 2, sceneY: element.y }, + { sceneX: x1 + element.width / 2, sceneY: y1 }, appState, ); const x = viewportX - appState.offsetLeft - CONTAINER_WIDTH / 2; @@ -425,13 +426,13 @@ export const shouldHideLinkPopup = ( if (isPointHittingElementBoundingBox(element, [sceneX, sceneY], threshold)) { return false; } - + const [x1, y1, x2] = getElementAbsoluteCoords(element); // hit box to prevent hiding when hovered in the vertical area between element and popover if ( - sceneX >= element.x && - sceneX <= element.x + element.width && - sceneY <= element.y && - sceneY >= element.y - SPACE_BOTTOM + sceneX >= x1 && + sceneX <= x2 && + sceneY >= y1 - SPACE_BOTTOM && + sceneY <= y1 ) { return false; }