From 8b632c9b05ca725a7714bfdef462afae6512d8fb Mon Sep 17 00:00:00 2001 From: Nikola Hristov <139394063+iexavl@users.noreply.github.com> Date: Mon, 31 Aug 2026 21:52:19 +0300 Subject: [PATCH] gh-15182: Fix tab changing when handling tab close when group collapses (gh-15183) --- src/zen/split-view/ZenViewSplitter.mjs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/zen/split-view/ZenViewSplitter.mjs b/src/zen/split-view/ZenViewSplitter.mjs index 7b5f9ce1c..e464e16cd 100644 --- a/src/zen/split-view/ZenViewSplitter.mjs +++ b/src/zen/split-view/ZenViewSplitter.mjs @@ -160,7 +160,9 @@ class nsZenViewSplitter extends nsZenDOMOperatedFeature { if (groupIndex < 0) { return; } - this.removeTabFromGroup(tab, groupIndex, { forUnsplit: true }); + this.removeTabFromGroup(tab, groupIndex, { + forUnsplit: true, + }); } /** @@ -203,16 +205,21 @@ class nsZenViewSplitter extends nsZenDOMOperatedFeature { * @param {object} [options={}] - Additional options. * @param {boolean} [options.forUnsplit=false] - Whether the removal is for unsplitting. * @param {boolean} [options.dontRebuildGrid=false] - Whether to skip rebuilding the grid layout. - * @param {boolean} [options.changeTab=true] - Whether to change the selected tab. + * @param {boolean} [options.changeTab=undefined] - Whether to change the selected tab. If left unspecified, + * change the selected tab only if the current view is the group the removed tab was in. */ removeTabFromGroup( tab, groupIndex = undefined, - { forUnsplit = false, dontRebuildGrid = false, changeTab = true } = {} + { forUnsplit = false, dontRebuildGrid = false, changeTab = undefined } = {} ) { if (typeof groupIndex === "undefined") { groupIndex = this._data.findIndex(group => group.tabs.includes(tab)); } + + if (typeof changeTab === "undefined") { + changeTab = groupIndex === this.currentView; + } // If groupIndex === -1, so `this._data.findIndex` couldn't find the split group if (groupIndex < 0) { return;