From 5d733ac0d89d6fd65ac01999bfc8e68e9b52fe3d Mon Sep 17 00:00:00 2001 From: taekyoungc Date: Tue, 14 Apr 2026 00:41:14 +0900 Subject: [PATCH] =?UTF-8?q?Revert=20"=EC=9A=B4=EC=98=81=20=EB=A9=94?= =?UTF-8?q?=EB=89=B4=EC=97=90=EC=84=9C=20=EC=A7=80=EC=A0=95=ED=8C=90?= =?UTF-8?q?=EB=A7=A4=EC=86=8C=20=ED=99=9C=EC=84=B1=20=EC=83=81=ED=83=9C?= =?UTF-8?q?=EA=B0=80=20=EC=A4=91=EB=B3=B5=EB=90=98=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EB=B3=B4=EC=A0=95"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 48e5578611d2c81a04cdf921e74f01354d7660dd. --- app/Views/admin/layout.php | 38 ++++++++++++----------------------- app/Views/bag/layout/main.php | 37 +++++++++------------------------- 2 files changed, 23 insertions(+), 52 deletions(-) diff --git a/app/Views/admin/layout.php b/app/Views/admin/layout.php index 3494f30..1fc8265 100644 --- a/app/Views/admin/layout.php +++ b/app/Views/admin/layout.php @@ -16,28 +16,11 @@ $userNav = session_user_nav_display(); $currentPath = current_nav_request_path(); $adminNavTree = get_admin_nav_tree(); -$resolveAdminNavNodeMatchLen = static function (object $node) use ($currentPath): int { - $maxLen = -1; - foreach (menu_link_candidate_paths($node->mm_link ?? null, $currentPath) as $cand) { - if (menu_single_path_matches_request($cand, $currentPath, [])) { - $maxLen = max($maxLen, strlen($cand)); - } - } - return $maxLen; +/** DB 링크(mm_link)만 사용. 짧게 적은 항목(menus 등)은 실제 URI(admin/menus)와 맞춰 후보 비교 */ +$adminNavItemIsCurrent = static function (?string $mmLink) use ($currentPath): bool { + return menu_link_matches_request($mmLink, $currentPath, []); }; -$activeAdminTopNav = null; -$activeAdminTopLen = -1; -$activeAdminTopNum = PHP_INT_MAX; -foreach ($adminNavTree as $topNode) { - $nodeLen = $resolveAdminNavNodeMatchLen($topNode); - if ($nodeLen > $activeAdminTopLen || ($nodeLen === $activeAdminTopLen && (int) ($topNode->mm_num ?? 0) < $activeAdminTopNum)) { - $activeAdminTopNav = $topNode; - $activeAdminTopLen = $nodeLen; - $activeAdminTopNum = (int) ($topNode->mm_num ?? 0); - } -} - /** 메뉴가 DB에서 안 쓰일 때만(폴백 상단바) 세그먼트 기반 활성 */ $isActive = static function (string $path) use ($uri, $seg3) { if ($path === 'admin' || $path === '') return $uri === ''; @@ -110,7 +93,15 @@ body { overflow: hidden; } children); $parentLink = menu_link_preferred_href_path($navItem->mm_link ?? null, $currentPath); - $parentIsCurrent = ($activeAdminTopNav !== null && $navItem === $activeAdminTopNav); + $parentIsCurrent = $adminNavItemIsCurrent($navItem->mm_link ?? null); + if (! $parentIsCurrent && $hasChildren) { + foreach ($navItem->children as $ch) { + if ($adminNavItemIsCurrent($ch->mm_link ?? null)) { + $parentIsCurrent = true; + break; + } + } + } ?>