From ccbcaeb1fdb98ec324819c44fb2491d336570b57 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Tue, 21 Feb 2023 13:22:31 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/7428 --- app/src/layout/Wnd.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.ts index a91dc8ba7..65c3c1ef7 100644 --- a/app/src/layout/Wnd.ts +++ b/app/src/layout/Wnd.ts @@ -681,12 +681,18 @@ export class Wnd { } if (item.headElement) { if (item.headElement.classList.contains("item--focus")) { - let currentIndex = index + 1; - if (index === this.children.length - 1) { - currentIndex = index - 1; - } - if (this.children[currentIndex] && !closeAll) { - this.switchTab(this.children[currentIndex].headElement, true); + let latestHeadElement: HTMLElement + Array.from(item.headElement.parentElement.children).forEach((headItem: HTMLElement) => { + if (!headItem.isSameNode(item.headElement)) { + if (!latestHeadElement) { + latestHeadElement = headItem; + } else if (headItem.getAttribute("data-activetime") > latestHeadElement.getAttribute("data-activetime")) { + latestHeadElement = headItem; + } + } + }) + if (latestHeadElement && !closeAll) { + this.switchTab(latestHeadElement, true); } } if (animate) {