From 13bfb83bf6c3c4372ee74a4cad6b54e28f5c3cd2 Mon Sep 17 00:00:00 2001 From: Philipp Otto Date: Tue, 3 Sep 2024 09:43:37 +0200 Subject: [PATCH] fix: popup position for point-aligned popups when no mouse position is known (#447) Co-authored-by: afc163 --- src/index.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index f59b038..dce5f96 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -381,9 +381,7 @@ export function generateTrigger( React.useState(null); // =========================== Align ============================ - const [mousePos, setMousePos] = React.useState<[x: number, y: number]>([ - 0, 0, - ]); + const [mousePos, setMousePos] = React.useState<[x: number, y: number] | null>(null); const setMousePosByEvent = ( event: Pick, @@ -406,7 +404,7 @@ export function generateTrigger( ] = useAlign( mergedOpen, popupEle, - alignPoint ? mousePos : targetEle, + alignPoint && mousePos !== null ? mousePos : targetEle, popupPlacement, builtinPlacements, popupAlign,