Skip to content

Commit

Permalink
Fix popup overflowing outside the view port
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtcode committed Aug 18, 2023
1 parent 9d42da2 commit 400fe0e
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/common/components/view/view-popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ function ViewPopup({ id, rect, className, uniqueRef, padding, children, onRender

useLayoutEffect(() => {
updatePopupPosition();
// Editor needs more time to get its final dimensions
setTimeout(updatePopupPosition, 0);
}, [uniqueRef]);

function updatePopupPosition() {
Expand All @@ -40,9 +42,7 @@ function ViewPopup({ id, rect, className, uniqueRef, padding, children, onRender

let parent = containerRef.current.parentNode;
let viewRect = parent.getBoundingClientRect();
viewRect = [viewRect.left, viewRect.top, viewRect.right, viewRect.bottom];


viewRect = [0, 0, viewRect.width, viewRect.height];

let annotationCenterLeft = rect[0] + (rect[2] - rect[0]) / 2;

Expand All @@ -63,13 +63,8 @@ function ViewPopup({ id, rect, className, uniqueRef, padding, children, onRender
isTop = false;
}


xrect.current = rect;





pos.current = { top, left, isTop };

setPopupPosition({});
Expand Down

0 comments on commit 400fe0e

Please sign in to comment.