gh-15182: Fix tab changing when handling tab close when group collapses (gh-15183)

This commit is contained in:
Nikola Hristov
2026-08-31 21:52:19 +03:00
committed by GitHub
parent 67b6daaa0e
commit 8b632c9b05

View File

@@ -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;