From aff02184f80a38a6b293e8dc252feb7aa7ad8735 Mon Sep 17 00:00:00 2001 From: zadam Date: Sat, 7 Mar 2020 13:57:31 +0100 Subject: [PATCH] removed last tab should activate second to last --- src/public/javascripts/services/tab_manager.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/public/javascripts/services/tab_manager.js b/src/public/javascripts/services/tab_manager.js index fac7805f5..1addaa6e0 100644 --- a/src/public/javascripts/services/tab_manager.js +++ b/src/public/javascripts/services/tab_manager.js @@ -239,13 +239,20 @@ export default class TabManager extends Component { return; } - await this.triggerEvent('beforeTabRemove', {tabId}, true); + await this.triggerEvent('beforeTabRemove', {tabId}); if (this.tabContexts.length <= 1) { this.openAndActivateEmptyTab(); } - else if (tabContextToRemove.isActive()) { - this.activateNextTabCommand(); + else { + const idx = this.tabContexts.findIndex(tc => tc.tabId === tabId); + + if (idx === this.tabContexts.length - 1) { + this.activatePreviousTabCommand(); + } + else { + this.activateNextTabCommand(); + } } this.children = this.children.filter(tc => tc.tabId !== tabId);