wip: deal with multiple dialog z-index

This commit is contained in:
Yohan Boniface 2024-06-10 11:22:00 +02:00
parent b7dd771a7f
commit c599082eca

View file

@ -19,8 +19,18 @@ export default class Dialog {
this.container.close()
}
currentZIndex() {
return Math.max(
...Array.from(document.querySelectorAll('dialog')).map(
(el) => window.getComputedStyle(el).getPropertyValue('z-index') || 0
)
)
}
open({ className, content, modal } = {}) {
this.container.innerHTML = ''
const currentZIndex = this.currentZIndex()
if (currentZIndex) this.container.style.zIndex = currentZIndex + 1
if (modal) this.container.showModal()
else this.container.show()
if (className) {