From 30b1d5fc9317f5265d1156277eb95c15676d1f80 Mon Sep 17 00:00:00 2001 From: Bruno Charest Date: Tue, 31 Mar 2026 21:03:39 -0400 Subject: [PATCH] feat: auto-expand collapsed directories when focusing path in sidebar from dashboard navigation - Add expandTarget option to focusPathInSidebar function to control directory expansion behavior - Check if target directory is collapsed and click to expand before highlighting - Pass expandTarget: true when navigating to directories from dashboard to ensure visibility - Add async delay after expansion to allow DOM update before path highlighting --- frontend/app.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/app.js b/frontend/app.js index cb61bce..ec01d1e 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -2393,6 +2393,14 @@ } } + if (lastTargetItem && options && options.expandTarget) { + const targetContainer = document.getElementById(`dir-${vaultName}-${targetPath}`); + if (targetContainer && targetContainer.classList.contains("collapsed")) { + lastTargetItem.click(); + await new Promise((resolve) => setTimeout(resolve, 0)); + } + } + // Clear previous path selections and highlight the final target document.querySelectorAll(".tree-item.path-selected").forEach((el) => el.classList.remove("path-selected")); if (lastTargetItem) { @@ -2620,7 +2628,7 @@ if (clearBtn) clearBtn.style.display = "none"; await restoreSidebarTree(); if (entry.type === "directory") { - await focusPathInSidebar(entry.vault, entry.path, { alignToTop: true }); + await focusPathInSidebar(entry.vault, entry.path, { alignToTop: true, expandTarget: true }); } else { await openFile(entry.vault, entry.path); await focusPathInSidebar(entry.vault, entry.path, { alignToTop: false });