운영 메뉴에서 지정판매소 활성 상태가 중복되지 않도록 보정
상단 메뉴 활성 판정을 최장 경로 1건 우선으로 통일해 조회 화면에서 관리 메뉴가 함께 활성화되는 문제를 막았습니다.
This commit is contained in:
@@ -16,11 +16,28 @@ $userNav = session_user_nav_display();
|
||||
$currentPath = current_nav_request_path();
|
||||
$adminNavTree = get_admin_nav_tree();
|
||||
|
||||
/** DB 링크(mm_link)만 사용. 짧게 적은 항목(menus 등)은 실제 URI(admin/menus)와 맞춰 후보 비교 */
|
||||
$adminNavItemIsCurrent = static function (?string $mmLink) use ($currentPath): bool {
|
||||
return menu_link_matches_request($mmLink, $currentPath, []);
|
||||
$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;
|
||||
};
|
||||
|
||||
$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 === '';
|
||||
@@ -93,15 +110,7 @@ body { overflow: hidden; }
|
||||
<?php
|
||||
$hasChildren = ! empty($navItem->children);
|
||||
$parentLink = menu_link_preferred_href_path($navItem->mm_link ?? null, $currentPath);
|
||||
$parentIsCurrent = $adminNavItemIsCurrent($navItem->mm_link ?? null);
|
||||
if (! $parentIsCurrent && $hasChildren) {
|
||||
foreach ($navItem->children as $ch) {
|
||||
if ($adminNavItemIsCurrent($ch->mm_link ?? null)) {
|
||||
$parentIsCurrent = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$parentIsCurrent = ($activeAdminTopNav !== null && $navItem === $activeAdminTopNav);
|
||||
?>
|
||||
<div class="relative group">
|
||||
<a class="<?= $parentIsCurrent ? 'text-blue-700 font-bold border-b-2 border-blue-700 pb-3 -mb-3' : 'hover:text-blue-600' ?>"
|
||||
@@ -112,10 +121,13 @@ body { overflow: hidden; }
|
||||
<?php /* 사이트 메뉴와 동일: 호버 끊김 방지 pt-1, 키보드 포커스, z-index */ ?>
|
||||
<div class="absolute left-0 top-full z-50 hidden pt-1 min-w-[12rem] group-hover:block group-focus-within:block">
|
||||
<div class="bg-white border border-gray-200 rounded shadow-lg py-1">
|
||||
<?php
|
||||
$activeChild = site_nav_active_child_for_parent($navItem, $currentPath, []);
|
||||
?>
|
||||
<?php foreach ($navItem->children as $child): ?>
|
||||
<?php
|
||||
$childLink = menu_link_preferred_href_path($child->mm_link ?? null, $currentPath);
|
||||
$childIsCurrent = $adminNavItemIsCurrent($child->mm_link ?? null);
|
||||
$childIsCurrent = $activeChild !== null && $child === $activeChild;
|
||||
?>
|
||||
<?php if ($childLink !== ''): ?>
|
||||
<a href="<?= base_url($childLink) ?>"
|
||||
|
||||
Reference in New Issue
Block a user