From 091ffdeb5994187f8c1133fa0219bd2cb4fec645 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Mon, 9 Jun 2025 14:54:04 +0300 Subject: [PATCH] feat(share): allow viewing directories --- .../src/scripts/modules/expanders.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/share-theme/src/scripts/modules/expanders.ts b/packages/share-theme/src/scripts/modules/expanders.ts index a1dc6c5d7..c72fe8a1c 100644 --- a/packages/share-theme/src/scripts/modules/expanders.ts +++ b/packages/share-theme/src/scripts/modules/expanders.ts @@ -12,16 +12,21 @@ // } export default function setupExpanders() { - const expanders = Array.from(document.querySelectorAll("#menu .submenu-item")); - for (const ex of expanders) { - ex.addEventListener("click", e => { - if ((e.target as Element).closest(".submenu-item,.item") !== ex) return; + const expanders = Array.from(document.querySelectorAll("#menu .submenu-item .collapse-button")); + for (const expander of expanders) { + const li = expander.parentElement?.parentElement; + if (!li) { + continue; + } + + expander.addEventListener("click", e => { + if ((e.target as Element).closest(".submenu-item,.item") !== li) return; e.preventDefault(); e.stopPropagation(); - const ul = ex.querySelector("ul")!; + const ul = li.querySelector("ul")!; ul.style.height = `${ul.scrollHeight}px`; - setTimeout(() => ex.classList.toggle("expanded"), 1); + setTimeout(() => li.classList.toggle("expanded"), 1); setTimeout(() => ul.style.height = ``, 200); }); } -} \ No newline at end of file +}