Skip to content

Commit e4b64b2

Browse files
philippottoafc163
authored andcommitted
fix: popup position for point-aligned popups when no mouse position is known (#447)
Co-authored-by: afc163 <afc163@gmail.com>
1 parent 77e8f0d commit e4b64b2

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/index.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,7 @@ export function generateTrigger(
381381
React.useState<VoidFunction>(null);
382382

383383
// =========================== Align ============================
384-
const [mousePos, setMousePos] = React.useState<[x: number, y: number]>([
385-
0, 0,
386-
]);
384+
const [mousePos, setMousePos] = React.useState<[x: number, y: number] | null>(null);
387385

388386
const setMousePosByEvent = (
389387
event: Pick<React.MouseEvent, 'clientX' | 'clientY'>,
@@ -406,7 +404,7 @@ export function generateTrigger(
406404
] = useAlign(
407405
mergedOpen,
408406
popupEle,
409-
alignPoint ? mousePos : targetEle,
407+
alignPoint && mousePos !== null ? mousePos : targetEle,
410408
popupPlacement,
411409
builtinPlacements,
412410
popupAlign,

0 commit comments

Comments
 (0)