From 67d57e3060e0436581644ea51c87f76214308ba8 Mon Sep 17 00:00:00 2001 From: bicochan Date: Mon, 31 Mar 2025 18:23:46 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20getCurrentMenu=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/cs/src/entities/menu/lib/utils.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/cs/src/entities/menu/lib/utils.ts b/apps/cs/src/entities/menu/lib/utils.ts index ecd636a88..5606d7aa2 100644 --- a/apps/cs/src/entities/menu/lib/utils.ts +++ b/apps/cs/src/entities/menu/lib/utils.ts @@ -4,10 +4,11 @@ export const getCurrentMenu = ( menus: MenuItem[], pathname: string, ): MenuItem | null => { - return ( - menus.find((menu) => { - if (menu.children) return getCurrentMenu(menu.children, pathname); - return menu.urlPath === pathname; - }) ?? null - ); + for (const menu of menus) { + if (menu.children) { + return getCurrentMenu(menu.children, pathname); + } + if (menu.urlPath === pathname) return menu; + } + return null; };