Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
atomiks committed Jan 10, 2025
1 parent 5016515 commit f098d2c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 3 additions & 5 deletions docs/src/app/(private)/experiments/motion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ function AlwaysMounted() {

function NoOpacity() {
const [open, setOpen] = React.useState(false);
const action = React.useRef({ unmount: () => {} });
const actionRef = React.useRef({ unmount: () => {} });

return (
<Popover.Root open={open} onOpenChange={setOpen} action={action}>
<Popover.Root open={open} onOpenChange={setOpen} action={actionRef}>
<Popover.Trigger>Trigger</Popover.Trigger>
<AnimatePresence>
{open && (
Expand All @@ -75,9 +75,7 @@ function NoOpacity() {
animate={{ scale: 1 }}
exit={{ scale: 0 }}
onAnimationComplete={() => {
if (!open) {
action.current.unmount();
}
actionRef.current.unmount();
}}
/>
}
Expand Down
8 changes: 5 additions & 3 deletions packages/react/src/popover/root/usePopoverRoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ export function usePopoverRoot(params: usePopoverRoot.Parameters): usePopoverRoo
);

const handleUnmount = useEventCallback(() => {
setMounted(false);
setOpenReason(null);
if (!open) {
setMounted(false);
setOpenReason(null);
}
});

useAfterExitAnimation({
Expand Down Expand Up @@ -236,7 +238,7 @@ export namespace usePopoverRoot {
*/
closeDelay?: number;
/**
* A ref to manually unmount the popover.
* A ref to imperative actions.
*/
action?: React.RefObject<{ unmount: () => void }>;
}
Expand Down

0 comments on commit f098d2c

Please sign in to comment.