From f552119acd2aea5f84333988d96b8d0c910eec00 Mon Sep 17 00:00:00 2001 From: Ildar Kamalov Date: Wed, 23 Jul 2025 13:17:07 +0300 Subject: [PATCH] review fix --- client_v2/src/common/ui/Menu/Menu.tsx | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/client_v2/src/common/ui/Menu/Menu.tsx b/client_v2/src/common/ui/Menu/Menu.tsx index fc89ebb2..f1207179 100644 --- a/client_v2/src/common/ui/Menu/Menu.tsx +++ b/client_v2/src/common/ui/Menu/Menu.tsx @@ -24,19 +24,20 @@ export const Menu = ({ headerMenu }: Props) => { const isActive = (path: string | string[], full = false) => { const currentPath = location.pathname; + const paths = Array.isArray(path) ? path : [path]; - if (Array.isArray(path)) { - return path.some((p) => (full ? p === currentPath : currentPath === p || currentPath.startsWith(p + '/'))); - } + return paths.some((p) => { + if (currentPath === p) { + return true; + } - if (full) { - return path === currentPath; - } + if (full) { + return false; + } - return ( - currentPath === path || - (currentPath.startsWith(path) && (currentPath[path.length] === '/' || path.endsWith('/'))) - ); + const normalizedPath = p.endsWith('/') ? p : p + '/'; + return currentPath.startsWith(normalizedPath); + }); }; return (