Skip to content

Commit

Permalink
chore: return first active item
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasCharrier committed Nov 19, 2024
1 parent 1616e2d commit cb468c5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/app/(private)/(dashboard)/PrivateLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export function PrivateLayout({ children }: { children: React.ReactNode }) {
text: currentPage,
isActive: hasPathnameThisRegex(
pathname,
"^/community/[a-zA-Z]+.[a-zA-Z]+"
"^/community/[a-zA-Z]+.[a-zA-Z]+$"
),
items: [
{
Expand Down Expand Up @@ -348,7 +348,7 @@ export function PrivateLayout({ children }: { children: React.ReactNode }) {

const findActiveItem = (items: ItemLink[]) => {
let tree: ItemLink[] = [];
items.forEach((i) => {
for (const i of items) {
let childrenTree: ItemLink[] = [];
if (i.items && i.items.length) {
childrenTree = findActiveItem(i.items);
Expand All @@ -357,8 +357,9 @@ export function PrivateLayout({ children }: { children: React.ReactNode }) {
tree = [i, ...childrenTree];
} else if (i.isActive) {
tree = [i];
break;
}
});
}
return tree;
};

Expand Down

0 comments on commit cb468c5

Please sign in to comment.