From aff83e7c0c4aa3cd7b371fad83b7a78b33e3b9a5 Mon Sep 17 00:00:00 2001 From: Al Siam Date: Fri, 15 Dec 2023 16:24:00 +0600 Subject: [PATCH] fix: sidebar close on route change --- src/components/sidebar/sidebar.tsx | 55 ++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/src/components/sidebar/sidebar.tsx b/src/components/sidebar/sidebar.tsx index d06c816..8b048ea 100644 --- a/src/components/sidebar/sidebar.tsx +++ b/src/components/sidebar/sidebar.tsx @@ -1,6 +1,7 @@ "use client"; import Link from "next/link"; +import { usePathname } from "next/navigation"; import { useState } from "react"; const Sidebar = () => { @@ -9,49 +10,73 @@ const Sidebar = () => { const handleOpen = () => { setOpen(!open); }; + const handleClose = () => { + setOpen(false); + }; + + const pathUrl = usePathname(); return ( );