From 60291e08f1c58c5d08e941bf9558ca5b18e56bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Tue, 3 Mar 2026 16:08:02 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20[sidebar]=20=EB=A9=94=EB=89=B4=20?= =?UTF-8?q?=EA=B2=80=EC=83=89=20=EC=8B=9C=20=EB=8C=80=EB=B6=84=EB=A5=98=20?= =?UTF-8?q?=EA=B7=B8=EB=A3=B9=EB=8F=84=20=EA=B2=80=EC=83=89=20=EB=8C=80?= =?UTF-8?q?=EC=83=81=EC=97=90=20=ED=8F=AC=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 그룹 헤더(대분류/서브그룹)도 검색어 매칭 대상으로 추가 - 그룹 헤더 매칭 시 하위 전체 메뉴 표시 + 하이라이트 적용 --- resources/views/partials/sidebar.blade.php | 54 +++++++++++++++++++++- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/resources/views/partials/sidebar.blade.php b/resources/views/partials/sidebar.blade.php index cc79059c..40b38a38 100644 --- a/resources/views/partials/sidebar.blade.php +++ b/resources/views/partials/sidebar.blade.php @@ -1172,14 +1172,57 @@ function filterMenus(query, skipSave) { } let matchCount = 0; + const groupHeaderMatches = new Set(); // 그룹 헤더가 매칭된 li 추적 - // 모든 메뉴 아이템 순회 + // 1단계: 그룹 헤더(대분류/서브그룹) 매칭 확인 + sidebarNav.querySelectorAll('li').forEach(li => { + const groupBtn = li.querySelector(':scope > button.sidebar-group-header, :scope > button.sidebar-subgroup-header'); + if (!groupBtn) return; + + const groupText = (groupBtn.querySelector('.sidebar-text')?.textContent || '').trim().toLowerCase(); + if (groupText.includes(query)) { + groupHeaderMatches.add(li); + } + }); + + // 2단계: 모든 메뉴 아이템 순회 const menuItems = sidebarNav.querySelectorAll('li'); menuItems.forEach(li => { + // 그룹 헤더가 매칭된 경우: 헤더 자체 + 모든 하위 메뉴 표시 + if (groupHeaderMatches.has(li)) { + li.style.display = ''; + li.classList.add('menu-search-match'); + li.classList.remove('menu-search-hidden'); + matchCount++; + + // 그룹 헤더에 하이라이트 적용 + const groupBtn = li.querySelector(':scope > button.sidebar-group-header, :scope > button.sidebar-subgroup-header'); + if (groupBtn) highlightText(groupBtn, query); + + // 하위 모든 메뉴 표시 + li.querySelectorAll('li').forEach(child => { + child.style.display = ''; + child.classList.remove('menu-search-hidden'); + }); + + // 부모 그룹들도 표시 + showParentGroups(li); + return; + } + + // 매칭된 그룹 헤더의 하위 항목이면 이미 처리됨 — 스킵 + let isChildOfMatchedGroup = false; + for (const matched of groupHeaderMatches) { + if (matched !== li && matched.contains(li)) { + isChildOfMatchedGroup = true; + break; + } + } + if (isChildOfMatchedGroup) return; + const link = li.querySelector('a[href], span[title]'); if (!link) { - // 그룹 헤더 등은 일단 숨김 li.style.display = 'none'; return; } @@ -1222,6 +1265,13 @@ function filterMenus(query, skipSave) { group.style.display = 'none'; } }); + + // 매칭된 그룹 헤더의 하위 그룹도 펼치기 + groupHeaderMatches.forEach(li => { + li.querySelectorAll('[id^="menu-group-"]').forEach(group => { + group.style.display = 'block'; + }); + }); } // 부모 그룹 표시