Revert "Bug 1965343 - Adopt whole tab group at once in replaceGroupWithWindow r=tabbrowser-reviewers,sthompson" for causing bc failures @browser_tab_groups.js.

This reverts commit fac3f86e95.
This commit is contained in:
agoloman
2025-05-15 21:06:19 +03:00
committed by agoloman@mozilla.com
parent dcc1cd7d98
commit 4b62de7961
4 changed files with 41 additions and 15 deletions

View File

@@ -5729,15 +5729,11 @@
/**
* Moves a tab to a new browser window, unless it's already the only tab
* in the current window, in which case this will do nothing.
*
* @param {MozTabbrowserTab|MozTabbrowserTabGroup|MozTabbrowserTabGroup.labelElement} aTab
*/
replaceTabWithWindow(aTab, aOptions) {
if (this.tabs.length == 1) {
return null;
}
// If aTab is a tab group, callers should check that it is not the only
// element in its window.
var options = "chrome,dialog=no,all";
for (var name in aOptions) {
@@ -5750,7 +5746,7 @@
// Play the tab closing animation to give immediate feedback while
// waiting for the new window to appear.
if (!gReduceMotion && this.isTab(aTab)) {
if (!gReduceMotion) {
aTab.style.maxWidth = ""; // ensure that fade-out transition happens
aTab.removeAttribute("fadein");
}
@@ -5845,7 +5841,42 @@
* The tab group to move.
*/
replaceGroupWithWindow(group) {
return this.replaceTabWithWindow(group);
// The first tab added to the new window will be selected.
// If a tab in the group is selected, adopt it first.
let selectedIndex = group.tabs.indexOf(gBrowser.selectedTab);
if (selectedIndex < 0) {
// Otherwise, we'll first adopt the first tab in the group
selectedIndex = 0;
}
let firstTab = group.tabs[selectedIndex];
group.removedByAdoption = true;
let newWindow = this.replaceTabWithWindow(firstTab);
newWindow.addEventListener(
"before-initial-tab-adopted",
() => {
let tabsToGroup = group.tabs.map((tab, i) => {
// addtabGroup will handle adopting the other tabs, but we already
// started adopting the tab at selectedIndex so we need to swap
// the old tab out for the new one.
if (i == selectedIndex) {
return newWindow.gBrowser.visibleTabs[0];
}
return tab;
});
// The initial tab isn't fully adopted yet, but the tab object has been
// instantiated, so we can make a group now.
newWindow.gBrowser.addTabGroup(tabsToGroup, {
id: group.id,
label: group.label,
color: group.color,
isAdoptingGroup: true,
});
Glean.tabgroup.groupInteractions.move_window.add(1);
},
{ once: true }
);
return newWindow;
}
/**