From e8c17ea94e3972f43ec45f4f34dd4e826be1a013 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste WATENBERG Date: Wed, 17 Apr 2024 11:59:19 +0200 Subject: [PATCH] fix sorting algorithm to determine the current navbar entry --- shell-ui/src/navbar/NavBar.tsx | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/shell-ui/src/navbar/NavBar.tsx b/shell-ui/src/navbar/NavBar.tsx index 944891350e..0794bc0a1c 100644 --- a/shell-ui/src/navbar/NavBar.tsx +++ b/shell-ui/src/navbar/NavBar.tsx @@ -159,22 +159,18 @@ export const useNavbarLinksToActions = ( .sort((a, b) => { if (!a.view.isFederated || !b.view.isFederated) { return 0; - } - if (a.view.view.path === '/') { - return -1; - } - if (a.view.view.exact && !b.view.view.exact) { - return -1; - } - if (!a.view.view.exact && b.view.view.exact) { - return 1; - } - if (a.view.view.strict && !b.view.view.strict) { + } else if ( + (a.view.view.exact && !b.view.view.exact) || + (a.view.view.strict && !b.view.view.strict) + ) { return -1; - } - if (!a.view.view.strict && b.view.view.strict) { + } else if ( + (!a.view.view.exact && b.view.view.exact) || + (!a.view.view.strict && b.view.view.strict) + ) { return 1; } + return 0; }) .find((link) =>