From b1db88625b28c7b26f92713b02ff73b87976f582 Mon Sep 17 00:00:00 2001 From: Arnei Date: Fri, 8 May 2026 12:56:30 +0200 Subject: [PATCH] Fix Imprint/Privacy page breaking the app Opening one of the two about pages would crash the admin ui. This should fix that. --- src/components/shared/MainNav.tsx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/components/shared/MainNav.tsx b/src/components/shared/MainNav.tsx index 6d126f647d..09c8ecd35e 100644 --- a/src/components/shared/MainNav.tsx +++ b/src/components/shared/MainNav.tsx @@ -174,14 +174,18 @@ const MainNav = ({ // current view is always the first element. Otherwise, NavLink will not // recognize the current view as active. if (firstPathFragment.length > 0) { - const arrToSort = linkMap[firstPathFragment as keyof typeof linkMap].links; - if (arrToSort != undefined && arrToSort.length > 1) { - arrToSort.forEach(item => { + const linkMapItem = linkMap[firstPathFragment as keyof typeof linkMap]; + + if (linkMapItem?.links && linkMapItem.links.length > 1) { + const arrToSort = linkMapItem.links; + if (arrToSort != undefined && arrToSort.length > 1) { + arrToSort.forEach(item => { + // @ts-expect-error: TODO: Someone else can fix this + if (item.path === pathname) { item.tmpIndex = 0; } else { item.tmpIndex = 1; } + }); // @ts-expect-error: TODO: Someone else can fix this - if (item.path === pathname) { item.tmpIndex = 0; } else { item.tmpIndex = 1; } - }); - // @ts-expect-error: TODO: Someone else can fix this - arrToSort.sort((a, b) => a.tmpIndex - b.tmpIndex); + arrToSort.sort((a, b) => a.tmpIndex - b.tmpIndex); + } } }