Fixed closing parent tab on glance

This commit is contained in:
mr. M 2024-11-01 13:47:01 +01:00
parent 3242919033
commit 76f4f80a75
No known key found for this signature in database
GPG key ID: CBD57A2AEDBDA1FB

View file

@ -10,6 +10,7 @@
init() {
document.documentElement.setAttribute("zen-glance-uuid", gZenUIManager.generateUuidv4());
window.addEventListener("keydown", this.onKeyDown.bind(this));
window.addEventListener("TabClose", this.onTabClose.bind(this));
ChromeUtils.defineLazyGetter(
this,
@ -122,7 +123,7 @@
});
}
closeGlance({ noAnimation = false } = {}) {
closeGlance({ noAnimation = false, onTabClose = false } = {}) {
if (this.#animating || !this.#currentBrowser || this.animatingOpen) {
return;
}
@ -143,7 +144,12 @@
window.requestAnimationFrame(() => {
this.browserWrapper.setAttribute("animate", true);
setTimeout(() => {
this.quickCloseGlance({ closeParentTab: false });
if (!this.currentParentTab) {
return;
}
if (!onTabClose) {
this.quickCloseGlance({ closeParentTab: false });
}
this.overlay.setAttribute("hidden", true);
this.overlay.removeAttribute("fade-out");
this.browserWrapper.removeAttribute("animate");
@ -155,7 +161,9 @@
this.#currentTab = null;
this.currentParentTab = null;
gBrowser.selectedTab = this.currentParentTab;
if (!onTabClose) {
gBrowser.selectedTab = this.currentParentTab;
}
setTimeout(() => {
gBrowser.removeTab(this.lastCurrentTab);
@ -181,6 +189,8 @@
this.#currentBrowser.docShellIsActive = true;
this.#currentBrowser.setAttribute("zen-glance-selected", true);
this.currentParentTab._visuallySelected = true;
this.currentParentTab.linkedBrowser.closest(".browserSidebarContainer").classList.add("zen-glance-background");
this._duringOpening = false;
}
@ -197,6 +207,9 @@
if (closeCurrentTab) {
this.#currentBrowser.docShellIsActive = false;
}
if (!this.currentParentTab._visuallySelected) {
this.currentParentTab._visuallySelected = false;
}
this.#currentBrowser.removeAttribute("zen-glance-selected");
this.currentParentTab.linkedBrowser.closest(".browserSidebarContainer").classList.remove("zen-glance-background");
}
@ -216,6 +229,12 @@
}
}
onTabClose(event) {
if (event.target === this.currentParentTab) {
this.closeGlance({ onTabClose: true });
}
}
fullyOpenGlance() {
gBrowser._insertTabAtIndex(this.#currentTab, {
index: this.#currentTab._tPos + 1,