From 093878422b78f9aa585e340c73db972f65069f22 Mon Sep 17 00:00:00 2001 From: Philipp Otto Date: Fri, 8 Mar 2024 15:26:36 +0100 Subject: [PATCH 1/2] don't initialize mouse position with [0, 0] to ensure that a popup is still placed at its target when alignPoint is true, but no mouse position is known --- src/index.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index d55c6b1d..3f551aa1 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -374,9 +374,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, @@ -399,7 +397,7 @@ export function generateTrigger( ] = useAlign( mergedOpen, popupEle, - alignPoint ? mousePos : targetEle, + alignPoint && mousePos != null ? mousePos : targetEle, popupPlacement, builtinPlacements, popupAlign, From 4e66204f97b89db7166511ed4a6a47509f6a4d57 Mon Sep 17 00:00:00 2001 From: Philipp Otto Date: Mon, 11 Mar 2024 10:03:14 +0100 Subject: [PATCH 2/2] use !== instead of != for null check Co-authored-by: afc163 --- src/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index 3f551aa1..7804d56f 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -397,7 +397,7 @@ export function generateTrigger( ] = useAlign( mergedOpen, popupEle, - alignPoint && mousePos != null ? mousePos : targetEle, + alignPoint && mousePos !== null ? mousePos : targetEle, popupPlacement, builtinPlacements, popupAlign,