운영 메뉴에서 지정판매소 활성 상태가 중복되지 않도록 보정

상단 메뉴 활성 판정을 최장 경로 1건 우선으로 통일해 조회 화면에서 관리 메뉴가 함께 활성화되는 문제를 막았습니다.
This commit is contained in:
taekyoungc
2026-04-14 00:33:24 +09:00
parent 078fa5d0c2
commit 48e5578611
2 changed files with 52 additions and 23 deletions

View File

@@ -13,6 +13,28 @@ if ($effectiveLgIdx) {
$effectiveLgName = $lgRow ? $lgRow->lg_name : null;
}
$userNav = session_user_nav_display();
$resolveNavNodeMatchLen = static function (object $node) use ($currentPath, $dashboardPathAliases): int {
$maxLen = -1;
foreach (menu_link_candidate_paths($node->mm_link ?? null, $currentPath) as $cand) {
if (menu_single_path_matches_request($cand, $currentPath, $dashboardPathAliases)) {
$maxLen = max($maxLen, strlen($cand));
}
}
return $maxLen;
};
$activeTopNav = null;
$activeTopLen = -1;
$activeTopNum = PHP_INT_MAX;
foreach ($siteNavTree as $topNode) {
$nodeLen = $resolveNavNodeMatchLen($topNode);
if ($nodeLen > $activeTopLen || ($nodeLen === $activeTopLen && (int) ($topNode->mm_num ?? 0) < $activeTopNum)) {
$activeTop = $topNode;
$activeTopLen = $nodeLen;
$activeTopNum = (int) ($topNode->mm_num ?? 0);
}
}
?>
<!DOCTYPE html>
<html lang="ko">
@@ -71,15 +93,7 @@ body { overflow: hidden; }
<?php foreach ($siteNavTree as $navItem): ?>
<?php
$navLink = menu_link_preferred_href_path($navItem->mm_link ?? null, $currentPath);
$isActive = site_nav_link_matches_current($navItem->mm_link ?? null, $currentPath, $dashboardPathAliases);
if (! $isActive && ! empty($navItem->children)) {
foreach ($navItem->children as $ch) {
if (site_nav_link_matches_current($ch->mm_link ?? null, $currentPath, $dashboardPathAliases)) {
$isActive = true;
break;
}
}
}
$isActive = ($activeTop !== null && $navItem === $activeTop);
?>
<div class="relative group">
<a class="<?= $isActive ? 'text-blue-700 font-bold border-b-2 border-blue-700 pb-3 -mb-3' : 'hover:text-blue-600' ?>"
@@ -90,10 +104,13 @@ body { overflow: hidden; }
<?php /* -mt-1 + pt-2: 부모 링크와 패널이 살짝 겹쳐 호버가 끊기지 않게 함. z-index: 드롭다운 클릭 우선 */ ?>
<div class="absolute left-0 top-full z-[200] -mt-1 pt-2 min-w-[12rem] hidden 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, $dashboardPathAliases);
?>
<?php foreach ($navItem->children as $child): ?>
<?php
$childLink = menu_link_preferred_href_path($child->mm_link ?? null, $currentPath);
$childCurrent = menu_link_matches_request($child->mm_link ?? null, $currentPath, $dashboardPathAliases);
$childCurrent = $activeChild !== null && $child === $activeChild;
?>
<?php if ($childLink !== ''): ?>
<a href="<?= base_url($childLink) ?>"