Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

fix: open navigation item by default (#716)

Manuelc4b54ed36c2d
diff --git a/apps/nextjs/src/components/layout/navigation-link.tsx b/apps/nextjs/src/components/layout/navigation-link.tsx
index c65f9381c..6aec0a9f1 100644
--- a/apps/nextjs/src/components/layout/navigation-link.tsx
+++ b/apps/nextjs/src/components/layout/navigation-link.tsx
@@ -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;