From 0c08126752da7453fd520cd6aef189b9d785bd05 Mon Sep 17 00:00:00 2001 From: soulsands <407221377@qq.com> Date: Thu, 13 Apr 2023 21:16:10 +0800 Subject: [PATCH] activating after removal of subContexts conforms to mainContexts --- src/public/app/components/tab_manager.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/public/app/components/tab_manager.js b/src/public/app/components/tab_manager.js index 92e94b218..e5ca32c45 100644 --- a/src/public/app/components/tab_manager.js +++ b/src/public/app/components/tab_manager.js @@ -388,7 +388,12 @@ export default class TabManager extends Component { await this.triggerEvent('beforeNoteContextRemove', { ntxIds: ntxIdsToRemove }); if (!noteContextToRemove.isMainContext()) { - await this.activateNoteContext(noteContextToRemove.getMainContext().ntxId); + const siblings = noteContextToRemove.getMainContext().getSubContexts(); + const idx = siblings.findIndex(nc => nc.ntxId === noteContextToRemove.ntxId); + const contextToActivateIdx = idx === siblings.length - 1 ? idx - 1 : idx + 1; + const contextToActivate = siblings[contextToActivateIdx]; + + await this.activateNoteContext(contextToActivate.ntxId); } else if (this.mainNoteContexts.length <= 1) { await this.openAndActivateEmptyTab();