From be8eafad5fa6c1b4dc24bf058a3a518674651bd6 Mon Sep 17 00:00:00 2001 From: Mauro Balades Date: Thu, 22 Aug 2024 20:23:41 +0200 Subject: [PATCH] Fixed closing workspaces --- src/ZenWorkspaces.mjs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/ZenWorkspaces.mjs b/src/ZenWorkspaces.mjs index 851730d..e630c8c 100644 --- a/src/ZenWorkspaces.mjs +++ b/src/ZenWorkspaces.mjs @@ -82,6 +82,9 @@ var ZenWorkspaces = { }, handleTabClose(event) { + if (this.__contextIsDelete) { + return; // Bug when closing tabs from the context menu + } let tab = event.target; let workspaceID = tab.getAttribute("zen-workspace-id"); // If the tab is the last one in the workspace, create a new tab @@ -186,14 +189,14 @@ var ZenWorkspaces = { `); - childs.querySelector(".zen-workspace-actions").addEventListener("command", ((event) => { + childs.querySelector(".zen-workspace-actions").addEventListener("command", (event) => { let button = event.target; this._contextMenuId = button.closest("toolbarbutton[zen-workspace-id]").getAttribute("zen-workspace-id"); const popup = button.ownerDocument.getElementById( "zenWorkspaceActionsMenu" ); popup.openPopup(button, "after_end"); - }).bind(this)); + }); element.appendChild(childs); element.onclick = (async () => { if (event.target.closest(".zen-workspace-actions")) { @@ -464,8 +467,11 @@ var ZenWorkspaces = { await this.changeWorkspace(workspace); }, - async contextDelete() { - await this.removeWorkspace(this._contextMenuId); + contextDelete(event) { + event.stopPropagation(); + this.__contextIsDelete = true; + this.removeWorkspace(this._contextMenuId); + this.__contextIsDelete = false; }, async changeWorkspaceShortcut() {