mirror of
https://github.com/zen-browser/desktop.git
synced 2026-02-05 19:37:22 +00:00
fix: Fixed workspaces not switching when they need to if the target tab is an essential, b=(no-bug), c=workspaces
This commit is contained in:
@@ -2778,7 +2778,9 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
||||
// Check if we need to change workspace
|
||||
if (
|
||||
tab.getAttribute('zen-workspace-id') !== this.activeWorkspace ||
|
||||
(currentWorkspace.containerTabId !== tab.getAttribute('usercontextid') && this.containerSpecificEssentials)
|
||||
tab.hasAttribute('zen-essential') ||
|
||||
(currentWorkspace.containerTabId !== parseInt(tab.parentNode.getAttribute('container')) &&
|
||||
this.containerSpecificEssentials)
|
||||
) {
|
||||
// Use a mutex-like approach to prevent concurrent workspace changes
|
||||
if (this._workspaceChangeInProgress) {
|
||||
@@ -2786,12 +2788,22 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
||||
return;
|
||||
}
|
||||
|
||||
let workspaceToSwitch = undefined;
|
||||
if (tab.hasAttribute('zen-essential')) {
|
||||
// Find first workspace with the same container
|
||||
const containerTabId = parseInt(tab.parentNode.getAttribute('container'));
|
||||
workspaceToSwitch = this._workspaceCache.workspaces.find((workspace) => workspace.containerTabId === containerTabId);
|
||||
} else {
|
||||
workspaceToSwitch = this._workspaceCache.workspaces.find((workspace) => workspace.uuid === tab.getAttribute('zen-workspace-id'));
|
||||
}
|
||||
if (!workspaceToSwitch) {
|
||||
console.error('No workspace found for tab, cannot switch');
|
||||
return;
|
||||
}
|
||||
|
||||
this._workspaceChangeInProgress = true;
|
||||
try {
|
||||
await this.changeWorkspace({
|
||||
uuid: tab.getAttribute('zen-workspace-id'),
|
||||
containerTabId: tab.getAttribute('usercontextid'),
|
||||
});
|
||||
await this.changeWorkspace(workspaceToSwitch);
|
||||
} finally {
|
||||
this._workspaceChangeInProgress = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user