unregister closed/destroyed overlay panels

This commit is contained in:
Gani Georgiev
2023-01-30 16:28:24 +02:00
parent eb51cdf1aa
commit 8b93aac8e3
29 changed files with 122 additions and 116 deletions
+18 -12
View File
@@ -68,15 +68,9 @@
}
$: if (active) {
// add helper body class
CommonHelper.pushUnique(activePanels, uniqueId);
document.body.classList.add("overlay-active");
registerActivePanel();
} else {
// remove helper body class if there are no other active panels
CommonHelper.removeByValue(activePanels, uniqueId);
if (!activePanels.length) {
document.body.classList.remove("overlay-active");
}
unregisterActivePanel();
}
export function show() {
@@ -129,6 +123,20 @@
}
}
function registerActivePanel() {
CommonHelper.pushUnique(activePanels, uniqueId);
document.body.classList.add("overlay-active");
}
function unregisterActivePanel() {
CommonHelper.removeByValue(activePanels, uniqueId);
if (!activePanels.length) {
document.body.classList.remove("overlay-active");
}
}
function highestZIndex() {
return 1000 + getHolder().querySelectorAll(".overlay-panel-container.active").length;
}
@@ -196,14 +204,12 @@
return () => {
clearTimeout(contentScrollThrottle);
unregisterActivePanel();
// ensures that no artifacts remains
// (currently there is a bug with svelte transition)
wrapper?.classList?.add("hidden");
if (!activePanels.length) {
document.body.classList.remove("overlay-active");
}
setTimeout(() => {
wrapper?.remove();
}, 0);