mirror of
https://github.com/zen-browser/components.git
synced 2025-07-07 21:49:59 +02:00
Fix: Handle TabClose event in ZenPinnedTabManager
This commit addresses a bug where the `TabClose` event was not being handled correctly by the `ZenPinnedTabManager`. This resulted in incorrect behavior when closing tabs, particularly in the context of multiple windows. The following changes were made: - The `TabClose` event is now handled explicitly within the `_onTabEvent` method. - The `_removePinnedAttributes` method is called to remove any pinned attributes associated with the closed tab. - The `_onCloseTabShortcut` method is updated to use `e.target?.closest("tab")` to ensure it targets the correct tab element. This fix ensures that pinned tab attributes are properly removed when a tab is closed, preventing unexpected behavior and data inconsistencies.
This commit is contained in:
parent
a82e2c2765
commit
eb2df8cb18
1 changed files with 7 additions and 8 deletions
|
@ -178,10 +178,9 @@
|
||||||
delete tab._zenClickEventListener;
|
delete tab._zenClickEventListener;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// TODO: Do this in a better way. Closing a second window could trigger remove tab and delete it from db
|
case "TabClose":
|
||||||
// case "TabClose":
|
this._removePinnedAttributes(tab);
|
||||||
// this._removePinnedAttributes(tab);
|
break;
|
||||||
// break;
|
|
||||||
default:
|
default:
|
||||||
console.warn('ZenPinnedTabManager: Unhandled tab event', action);
|
console.warn('ZenPinnedTabManager: Unhandled tab event', action);
|
||||||
break;
|
break;
|
||||||
|
@ -189,8 +188,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
_onTabClick(e) {
|
_onTabClick(e) {
|
||||||
const tab = e.target;
|
const tab = e.target?.closest("tab");
|
||||||
if (e.button === 1) {
|
if (e.button === 1 && tab) {
|
||||||
this._onCloseTabShortcut(e, tab);
|
this._onCloseTabShortcut(e, tab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -393,7 +392,7 @@
|
||||||
|
|
||||||
const element = window.MozXULElement.parseXULToFragment(`
|
const element = window.MozXULElement.parseXULToFragment(`
|
||||||
<menuitem id="context_zen-pin-tab-global"
|
<menuitem id="context_zen-pin-tab-global"
|
||||||
data-lazy-l10n-id="pin-tab-global"
|
data-lazy-l10n-id="tab-context-zen-pin-tab-global"
|
||||||
hidden="true"
|
hidden="true"
|
||||||
oncommand="gZenPinnedTabManager._addGlobalPin();"/>
|
oncommand="gZenPinnedTabManager._addGlobalPin();"/>
|
||||||
`);
|
`);
|
||||||
|
@ -413,7 +412,7 @@
|
||||||
const isVisible = contextTab.pinned && !contextTab.multiselected;
|
const isVisible = contextTab.pinned && !contextTab.multiselected;
|
||||||
document.getElementById("context_zen-reset-pinned-tab").hidden = !isVisible || !contextTab.getAttribute("zen-pin-id");
|
document.getElementById("context_zen-reset-pinned-tab").hidden = !isVisible || !contextTab.getAttribute("zen-pin-id");
|
||||||
document.getElementById("context_zen-replace-pinned-url-with-current").hidden = !isVisible;
|
document.getElementById("context_zen-replace-pinned-url-with-current").hidden = !isVisible;
|
||||||
document.getElementById("context_zen-pin-tab-global").hidden = contextTab.pinned;
|
document.getElementById("context_zen-pin-tab-global").hidden = contextTab.pinned || !ZenWorkspaces.workspaceEnabled;
|
||||||
document.getElementById("context_zen-pinned-tab-separator").hidden = !isVisible;
|
document.getElementById("context_zen-pinned-tab-separator").hidden = !isVisible;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue