From dca61e14596483331e6b18af29b2e26a83b2f126 Mon Sep 17 00:00:00 2001 From: N-Pex Date: Thu, 12 Sep 2024 15:42:08 +0200 Subject: [PATCH] Close menu on selection (mobile only) --- apps/link/app/(main)/_components/InternalLayout.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apps/link/app/(main)/_components/InternalLayout.tsx b/apps/link/app/(main)/_components/InternalLayout.tsx index 36062cd..3748592 100644 --- a/apps/link/app/(main)/_components/InternalLayout.tsx +++ b/apps/link/app/(main)/_components/InternalLayout.tsx @@ -24,6 +24,7 @@ import { import { fonts } from "@link-stack/ui"; import Image from "next/image"; import LinkLogo from "public/link-logo-small.png"; +import { usePathname } from 'next/navigation'; interface InternalLayoutProps extends PropsWithChildren { setupModeActive: boolean; @@ -44,6 +45,15 @@ export const InternalLayout: FC = ({ const [openWidth, setOpenWidth] = useState(0); const [closedWidth, setClosedWidth] = useState(0); + const pathname = usePathname(); + + useEffect(() => { + // On mobile, close menu when stuff is selected + if (mobile) { + setOpen(false); + } + }, [pathname]); + useEffect(() => { setClosedWidth(mobile ? 0 : 70); setOpenWidth(270);