Skip to content

Commit

Permalink
fix: fix duplicate dependency issues
Browse files Browse the repository at this point in the history
  • Loading branch information
TinsFox committed Nov 2, 2024
1 parent c259d57 commit 6cd2c27
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/nav-sidebar/nav-main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import {
} from "@/components/ui/sidebar"
import type { IMenu } from "@/models/menu"

import { Button } from "../ui/button"

export function NavMain({
items,
}: {
Expand Down Expand Up @@ -59,7 +61,7 @@ export function NavMain({
if (hasChanges) {
setOpenItems(newOpenItems)
}
}, [location.pathname, items, isPathActive, isParentActive, setOpenItems, openItems])
}, [location.pathname, items, isPathActive, isParentActive])

const handleToggle = (title: string) => {
setOpenItems((prev) => ({
Expand All @@ -83,8 +85,10 @@ export function NavMain({
<SidebarGroup>
<div className="flex items-center justify-between px-2">
<SidebarGroupLabel>Platform</SidebarGroupLabel>
<button
<Button
type="button"
size="icon"
variant="ghost"
onClick={handleToggleAll}
className="rounded-md p-1 hover:bg-muted"
title={items.every((item) => openItems[item.title]) ? "Collapse all" : "Expand all"}
Expand All @@ -94,7 +98,7 @@ export function NavMain({
) : (
<Maximize2 className="size-4" />
)}
</button>
</Button>
</div>
<SidebarMenu>
{items.map((item) => (
Expand Down

0 comments on commit 6cd2c27

Please sign in to comment.