Skip to content

Commit

Permalink
Fix sidebar not closing in mobile properly
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchernchong committed Nov 22, 2024
1 parent fc6fecf commit 615667f
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions components/AppSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ export const AppSidebar = () => {
<SidebarHeader>
<SidebarMenu>
<SidebarMenuItem>
<SidebarMenuButton size="lg" asChild>
<SidebarMenuButton
asChild
size="lg"
onClick={() => setOpenMobile(false)}
>
<Link href="/">
<div className="flex flex-col gap-0.5 leading-none">
<BrandLogo />
Expand All @@ -77,7 +81,11 @@ export const AppSidebar = () => {
<SidebarGroupLabel>Cars</SidebarGroupLabel>
<SidebarMenu>
<SidebarMenuItem>
<SidebarMenuButton asChild isActive={pathname === "/cars"}>
<SidebarMenuButton
asChild
isActive={pathname === "/cars"}
onClick={() => setOpenMobile(false)}
>
<Link href="/cars">
<Gauge />
<span>Monthly Registrations</span>
Expand Down Expand Up @@ -127,7 +135,11 @@ export const AppSidebar = () => {
<SidebarMenu>
{data.coe.map(({ items, ...item }) => (
<SidebarMenuItem key={item.title}>
<SidebarMenuButton asChild isActive={item.url === pathname}>
<SidebarMenuButton
asChild
isActive={item.url === pathname}
onClick={() => setOpenMobile(false)}
>
<Link href={item.url}>
{item.icon && <item.icon />}
<span>{item.title}</span>
Expand All @@ -139,6 +151,7 @@ export const AppSidebar = () => {
<SidebarMenuSubButton
asChild
isActive={subItem.url === pathname}
onClick={() => setOpenMobile(false)}
>
<Link href={subItem.url}>
{subItem.icon && <subItem.icon />}
Expand Down

0 comments on commit 615667f

Please sign in to comment.