From 2d99bf6a8ff9a43c2847f8171a8d7d98b13be963 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 10 Nov 2023 18:26:29 +0800 Subject: [PATCH] :bug: fix https://github.com/siyuan-note/siyuan/issues/9624 --- app/src/layout/tabUtil.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/layout/tabUtil.ts b/app/src/layout/tabUtil.ts index 41dee7057..2c4cf4cfb 100644 --- a/app/src/layout/tabUtil.ts +++ b/app/src/layout/tabUtil.ts @@ -333,22 +333,24 @@ export const closeTabByType = async (tab: Tab, type: "closeOthers" | "closeAll" index--; } } - return; - } - if (type === "closeAll") { + } else if (type === "closeAll") { for (let index = 0; index < tab.parent.children.length; index++) { if (!tab.parent.children[index].headElement.classList.contains("item--pin")) { await tab.parent.children[index].parent.removeTab(tab.parent.children[index].id, true); index--; } } - return; - } - if (tabs.length > 0) { + } else if (tabs.length > 0) { for (let index = 0; index < tabs.length; index++) { if (!tabs[index].headElement.classList.contains("item--pin")) { await tabs[index].parent.removeTab(tabs[index].id); } } } + + if (tab.headElement.parentElement && !tab.headElement.parentElement.querySelector(".item--focus")) { + tab.parent.switchTab(tab.headElement, true); + } else if (tab.parent.children.length > 0) { + tab.parent.switchTab(tab.parent.children[tab.parent.children.length - 1].headElement, true); + } };