Skip to content

Commit

Permalink
fix: popup position for point-aligned popups when no mouse position i…
Browse files Browse the repository at this point in the history
…s known (#447)

Co-authored-by: afc163 <afc163@gmail.com>
  • Loading branch information
philippotto and afc163 committed Sep 3, 2024
1 parent c303c1f commit 13bfb83
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,7 @@ export function generateTrigger(
React.useState<VoidFunction>(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<React.MouseEvent, 'clientX' | 'clientY'>,
Expand All @@ -406,7 +404,7 @@ export function generateTrigger(
] = useAlign(
mergedOpen,
popupEle,
alignPoint ? mousePos : targetEle,
alignPoint && mousePos !== null ? mousePos : targetEle,
popupPlacement,
builtinPlacements,
popupAlign,
Expand Down

0 comments on commit 13bfb83

Please sign in to comment.