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 });