Refactor tab navigation logic in ZenWorkspaces.mjs

This commit is contained in:
mauro-balades 2024-09-09 20:27:52 +02:00
parent bdcc6a8c97
commit 26173f7cfb

View file

@ -457,7 +457,9 @@ var ZenWorkspaces = {
if ((tab.getAttribute('zen-workspace-id') === window.uuid && !tab.pinned) || !tab.hasAttribute('zen-workspace-id')) {
if (!firstTab) {
firstTab = tab;
gBrowser.selectedTab = firstTab;
} else if (gBrowser.selectedTab === tab) {
// If the selected tab is already in the workspace, we don't want to change it
firstTab = undefined;
}
gBrowser.showTab(tab);
if (!tab.hasAttribute('zen-workspace-id')) {
@ -467,6 +469,9 @@ var ZenWorkspaces = {
}
}
}
if (firstTab) {
gBrowser.selectedTab = firstTab;
}
if (typeof firstTab === 'undefined' && !onInit) {
this._createNewTabForWorkspace(window);
}