mirror of
https://github.com/zen-browser/desktop.git
synced 2025-10-21 01:02:44 +00:00
fix: improve tab selection logic for zen-glance-tab and streamline workspace switching
This commit is contained in:
@@ -2007,8 +2007,12 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const parent = browser.ownerGlobal;
|
let tab = gBrowser.getTabForBrowser(browser);
|
||||||
const tab = gBrowser.getTabForBrowser(browser);
|
if (tab.hasAttribute('zen-glance-tab')) {
|
||||||
|
// Extract from parent node so we are not selecting the wrong (current) tab
|
||||||
|
tab = tab.parentNode.closest('.tabbrowser-tab');
|
||||||
|
console.assert(tab, 'Tab not found for zen-glance-tab');
|
||||||
|
}
|
||||||
const workspaceID = tab.getAttribute('zen-workspace-id');
|
const workspaceID = tab.getAttribute('zen-workspace-id');
|
||||||
const isEssential = tab.getAttribute('zen-essential') === 'true';
|
const isEssential = tab.getAttribute('zen-essential') === 'true';
|
||||||
|
|
||||||
@@ -2017,20 +2021,19 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isEssential) {
|
if (!isEssential) {
|
||||||
const activeWorkspace = await parent.ZenWorkspaces.getActiveWorkspace();
|
const activeWorkspace = await this.getActiveWorkspace();
|
||||||
if (!activeWorkspace) {
|
if (!activeWorkspace) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only update last selected tab for non-essential tabs in their workspace
|
// Only update last selected tab for non-essential tabs in their workspace
|
||||||
if (!isEssential && workspaceID === activeWorkspace.uuid) {
|
if (workspaceID === activeWorkspace.uuid) {
|
||||||
this._lastSelectedWorkspaceTabs[workspaceID] = tab;
|
this._lastSelectedWorkspaceTabs[workspaceID] = tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch workspace if needed
|
// Switch workspace if needed
|
||||||
if (workspaceID && workspaceID !== activeWorkspace.uuid && parent.ZenWorkspaces._hasInitializedTabsStrip) {
|
if (workspaceID && workspaceID !== activeWorkspace.uuid && this._hasInitializedTabsStrip) {
|
||||||
const workspaces = await parent.ZenWorkspaces._workspaces();
|
await this.changeWorkspace({ uuid: workspaceID });
|
||||||
await parent.ZenWorkspaces.changeWorkspace({ uuid: workspaceID });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user