1
0
Fork 1
mirror of https://github.com/zen-browser/desktop.git synced 2025-07-08 04:49:59 +02:00

fix(workspaces): ensure onWindowResize is triggered after workspace removal and optimize button alignment logic

This commit is contained in:
mr. m 2025-03-21 00:48:43 +01:00
parent 5d1021350d
commit 04308fbaea
No known key found for this signature in database
GPG key ID: 419302196C23B258

View file

@ -873,6 +873,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
await ZenWorkspacesStorage.removeWorkspace(windowID); await ZenWorkspacesStorage.removeWorkspace(windowID);
await this._propagateWorkspaceData(); await this._propagateWorkspaceData();
await this._updateWorkspacesChangeContextMenu(); await this._updateWorkspacesChangeContextMenu();
this.onWindowResize();
} }
isWorkspaceActive(workspace) { isWorkspaceActive(workspace) {
@ -2379,14 +2380,16 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
if (!parent) { if (!parent) {
return; return;
} }
// Once we are overflowing, we align the buttons to always stay inside the container, window.requestAnimationFrame(() => {
// meaning we need to remove the overflow attribute to reset the width // Once we are overflowing, we align the buttons to always stay inside the container,
parent.removeAttribute('overflow'); // meaning we need to remove the overflow attribute to reset the width
const overflow = parent.scrollWidth > parent.clientWidth; parent.removeAttribute('overflow');
parent.toggleAttribute('overflow', overflow); const overflow = parent.scrollWidth > parent.clientWidth;
// The maximum width a button has when it overflows based on the number of buttons parent.toggleAttribute('overflow', overflow);
const numButtons = parent.children.length + 1; // +1 to exclude the active button // The maximum width a button has when it overflows based on the number of buttons
const maxWidth = 100 / numButtons; const numButtons = parent.children.length + 1; // +1 to exclude the active button
parent.style.setProperty('--zen-overflowed-workspace-button-width', `${maxWidth}%`); const maxWidth = 100 / numButtons;
parent.style.setProperty('--zen-overflowed-workspace-button-width', `${maxWidth}%`);
});
} }
})(); })();