diff --git a/src/components/AccountMenu.tsx b/src/components/AccountMenu.tsx index a792f60..daaafd1 100644 --- a/src/components/AccountMenu.tsx +++ b/src/components/AccountMenu.tsx @@ -9,13 +9,21 @@ type AccountMenuProps = { }; export default function AccountMenu({ customer }: AccountMenuProps) { + const [mounted, setMounted] = useState(false); const [open, setOpen] = useState(false); const [showLogoutConfirm, setShowLogoutConfirm] = useState(false); const ref = useRef(null); + useEffect(() => { + setMounted(true); + }, []); + useEffect(() => { const onClickOutside = (e: MouseEvent) => { - if (ref.current && !ref.current.contains(e.target as Node)) setOpen(false); + if (ref.current && !ref.current.contains(e.target as Node)) { + setOpen(false); + setShowLogoutConfirm(false); + } }; document.addEventListener('mousedown', onClickOutside); return () => document.removeEventListener('mousedown', onClickOutside); @@ -29,6 +37,8 @@ export default function AccountMenu({ customer }: AccountMenuProps) { ); } + if (!mounted) return null; + return (