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) => ( const NavLinkWithItems = (props: NavigationLinkWithItems) => {
<NavLink const pathname = usePathname();
style={{ const isActive = props.items.some((item) => item.href === pathname);
borderRadius: 5, return (
}} <NavLink
label={props.label} style={{
leftSection={props.icon} borderRadius: 5,
> }}
{props.items.map((item) => ( label={props.label}
<NavLinkHref key={item.label} {...item} /> leftSection={props.icon}
))} defaultOpened={isActive}
</NavLink> >
); {props.items.map((item) => (
<NavLinkHref key={item.label} {...item} />
))}
</NavLink>
);
};
interface CommonNavigationLinkProps { interface CommonNavigationLinkProps {
label: string; label: string;