fix: open navigation item by default (#716)
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user