fix: Fixed the window always closing with last tab, b=(no-bug), c=workspaces

This commit is contained in:
mr. m
2025-05-08 14:40:05 +02:00
parent bbb6ba4078
commit eff7cfc5fe
2 changed files with 10 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
index 6dece2b9d0462d90a28e75350ce983d87816ef73..4042f332a9d991c31a1725a0f2b4fffebc0d11d8 100644
index 6dece2b9d0462d90a28e75350ce983d87816ef73..fdcfd020326b45eb23cbe74d0ce53a06c17cde8a 100644
--- a/browser/components/tabbrowser/content/tabbrowser.js
+++ b/browser/components/tabbrowser/content/tabbrowser.js
@@ -415,11 +415,45 @@
@@ -461,7 +461,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4042f332a9d991c31a1725a0f2b4fffe
}
+ if (ZenWorkspaces.workspaceEnabled) {
+ let newTab = ZenWorkspaces.handleTabBeforeClose(aTab);
+ let newTab = ZenWorkspaces.handleTabBeforeClose(aTab, closeWindowWithLastTab);
+ if (newTab) {
+ this.selectedTab = newTab;
+ }

View File

@@ -801,6 +801,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
if (this._initialTab) {
if (this._initialTab._shouldRemove && this._initialTab._veryPossiblyEmpty) {
this._removedByStartupPage = true;
gBrowser.removeTab(this._initialTab, {
skipSessionStore: true,
animate: false,
@@ -818,6 +819,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
setTimeout(() => {
const tabs = gBrowser.tabs.filter((tab) => !tab.collapsed && !tab.hasAttribute('zen-empty-tab'));
gBrowser.selectedTab = tabs[this._tabToSelect];
this._removedByStartupPage = true;
gBrowser.removeTab(this._tabToRemoveForEmpty, {
skipSessionStore: true,
animate: false,
@@ -827,6 +829,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
} else {
this.selectEmptyTab();
showed = true;
this._removedByStartupPage = true;
gBrowser.removeTab(this._tabToRemoveForEmpty, {
skipSessionStore: true,
animate: false,
@@ -842,6 +845,9 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
}
handleInitialTab(tab, isEmpty) {
if (gZenUIManager.testingEnabled) {
return;
}
// note: We cant access `gZenVerticalTabsManager._canReplaceNewTab` this early
if (isEmpty && Services.prefs.getBoolPref('zen.urlbar.replace-newtab', true)) {
this._tabToRemoveForEmpty = tab;
@@ -877,7 +883,6 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
) {
// Remove any tabs where their workspace doesn't exist anymore
gBrowser.removeTab(tab, {
animate: false,
skipSessionStore: true,
closeWindowWithLastTab: false,
});
@@ -885,7 +890,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
}
}
handleTabBeforeClose(tab) {
handleTabBeforeClose(tab, closeWindowWithLastTab = false) {
if (!this.workspaceEnabled || this.__contextIsDelete || this._removedByStartupPage) {
return null;
}
@@ -897,8 +902,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
let tabs = gBrowser.visibleTabs;
let tabsPinned = tabs.filter((t) => !this.shouldOpenNewTabIfLastUnpinnedTabIsClosed || !t.pinned);
const shouldCloseWindow = this.shouldCloseWindow();
const shouldCloseWindow = this.shouldCloseWindow() && closeWindowWithLastTab;
if (tabs.length === 1 && tabs[0] === tab) {
if (shouldCloseWindow) {
// We've already called beforeunload on all the relevant tabs if we get here,