From 8f1a4dc801169935140226b849880ff8c02f77dd Mon Sep 17 00:00:00 2001 From: Nyoman Sunima Date: Tue, 31 Oct 2023 20:25:07 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8D=20fix:=20adding=20auto=20close=20e?= =?UTF-8?q?vent=20when=20the=20path=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/dynamic-logo.tsx | 1 - src/components/common/navigation-menu.tsx | 9 +++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/common/dynamic-logo.tsx b/src/components/common/dynamic-logo.tsx index d56e1cf..7f40030 100644 --- a/src/components/common/dynamic-logo.tsx +++ b/src/components/common/dynamic-logo.tsx @@ -1,6 +1,5 @@ 'use client' -import Image from 'next/image' import Link from 'next/link' import { usePathname } from 'next/navigation' import * as React from 'react' diff --git a/src/components/common/navigation-menu.tsx b/src/components/common/navigation-menu.tsx index 94d2cc3..34f4998 100644 --- a/src/components/common/navigation-menu.tsx +++ b/src/components/common/navigation-menu.tsx @@ -4,13 +4,22 @@ import { Button } from '@components/ui/button' import { Sheet, SheetContent } from '@components/ui/sheet' import { Tooltip, TooltipContent, TooltipTrigger } from '@components/ui/tooltip' import Link from 'next/link' +import { usePathname } from 'next/navigation' import * as React from 'react' import { sideNavMenus } from '~/constants/menu' import { socials } from '~/constants/social' export function NavigationMenu() { + const pathname = usePathname() const [isOpen, setOpen] = React.useState(false) + React.useEffect( + function closeSheetOnPathChange() { + setOpen(false) + }, + [pathname], + ) + return ( <>