fix: open navigation item by default (#716)

This commit is contained in:
Manuel
2024-06-26 12:19:05 +02:00
committed by GitHub
parent 988ec6bebb
commit c4b54ed36c

View File

@@ -35,19 +35,24 @@ const NavLinkHref = (props: NavigationLinkHref) => {
);
};
const NavLinkWithItems = (props: NavigationLinkWithItems) => (
<NavLink
style={{
borderRadius: 5,
}}
label={props.label}
leftSection={props.icon}
>
{props.items.map((item) => (
<NavLinkHref key={item.label} {...item} />
))}
</NavLink>
);
const NavLinkWithItems = (props: NavigationLinkWithItems) => {
const pathname = usePathname();
const isActive = props.items.some((item) => item.href === pathname);
return (
<NavLink
style={{
borderRadius: 5,
}}
label={props.label}
leftSection={props.icon}
defaultOpened={isActive}
>
{props.items.map((item) => (
<NavLinkHref key={item.label} {...item} />
))}
</NavLink>
);
};
interface CommonNavigationLinkProps {
label: string;