mirror of
https://github.com/zen-browser/components.git
synced 2025-07-07 16:35:30 +02:00
Fixed closing parent tab on glance
This commit is contained in:
parent
3242919033
commit
76f4f80a75
1 changed files with 22 additions and 3 deletions
|
@ -10,6 +10,7 @@
|
||||||
init() {
|
init() {
|
||||||
document.documentElement.setAttribute("zen-glance-uuid", gZenUIManager.generateUuidv4());
|
document.documentElement.setAttribute("zen-glance-uuid", gZenUIManager.generateUuidv4());
|
||||||
window.addEventListener("keydown", this.onKeyDown.bind(this));
|
window.addEventListener("keydown", this.onKeyDown.bind(this));
|
||||||
|
window.addEventListener("TabClose", this.onTabClose.bind(this));
|
||||||
|
|
||||||
ChromeUtils.defineLazyGetter(
|
ChromeUtils.defineLazyGetter(
|
||||||
this,
|
this,
|
||||||
|
@ -122,7 +123,7 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
closeGlance({ noAnimation = false } = {}) {
|
closeGlance({ noAnimation = false, onTabClose = false } = {}) {
|
||||||
if (this.#animating || !this.#currentBrowser || this.animatingOpen) {
|
if (this.#animating || !this.#currentBrowser || this.animatingOpen) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -143,7 +144,12 @@
|
||||||
window.requestAnimationFrame(() => {
|
window.requestAnimationFrame(() => {
|
||||||
this.browserWrapper.setAttribute("animate", true);
|
this.browserWrapper.setAttribute("animate", true);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.quickCloseGlance({ closeParentTab: false });
|
if (!this.currentParentTab) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!onTabClose) {
|
||||||
|
this.quickCloseGlance({ closeParentTab: false });
|
||||||
|
}
|
||||||
this.overlay.setAttribute("hidden", true);
|
this.overlay.setAttribute("hidden", true);
|
||||||
this.overlay.removeAttribute("fade-out");
|
this.overlay.removeAttribute("fade-out");
|
||||||
this.browserWrapper.removeAttribute("animate");
|
this.browserWrapper.removeAttribute("animate");
|
||||||
|
@ -155,7 +161,9 @@
|
||||||
this.#currentTab = null;
|
this.#currentTab = null;
|
||||||
this.currentParentTab = null;
|
this.currentParentTab = null;
|
||||||
|
|
||||||
gBrowser.selectedTab = this.currentParentTab;
|
if (!onTabClose) {
|
||||||
|
gBrowser.selectedTab = this.currentParentTab;
|
||||||
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
gBrowser.removeTab(this.lastCurrentTab);
|
gBrowser.removeTab(this.lastCurrentTab);
|
||||||
|
@ -181,6 +189,8 @@
|
||||||
this.#currentBrowser.docShellIsActive = true;
|
this.#currentBrowser.docShellIsActive = true;
|
||||||
this.#currentBrowser.setAttribute("zen-glance-selected", true);
|
this.#currentBrowser.setAttribute("zen-glance-selected", true);
|
||||||
|
|
||||||
|
this.currentParentTab._visuallySelected = true;
|
||||||
|
|
||||||
this.currentParentTab.linkedBrowser.closest(".browserSidebarContainer").classList.add("zen-glance-background");
|
this.currentParentTab.linkedBrowser.closest(".browserSidebarContainer").classList.add("zen-glance-background");
|
||||||
this._duringOpening = false;
|
this._duringOpening = false;
|
||||||
}
|
}
|
||||||
|
@ -197,6 +207,9 @@
|
||||||
if (closeCurrentTab) {
|
if (closeCurrentTab) {
|
||||||
this.#currentBrowser.docShellIsActive = false;
|
this.#currentBrowser.docShellIsActive = false;
|
||||||
}
|
}
|
||||||
|
if (!this.currentParentTab._visuallySelected) {
|
||||||
|
this.currentParentTab._visuallySelected = false;
|
||||||
|
}
|
||||||
this.#currentBrowser.removeAttribute("zen-glance-selected");
|
this.#currentBrowser.removeAttribute("zen-glance-selected");
|
||||||
this.currentParentTab.linkedBrowser.closest(".browserSidebarContainer").classList.remove("zen-glance-background");
|
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() {
|
fullyOpenGlance() {
|
||||||
gBrowser._insertTabAtIndex(this.#currentTab, {
|
gBrowser._insertTabAtIndex(this.#currentTab, {
|
||||||
index: this.#currentTab._tPos + 1,
|
index: this.#currentTab._tPos + 1,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue