fix: handle the 'auto' value special case for z-index

Fix #1997
This commit is contained in:
David Larlet 2024-07-15 13:33:07 -04:00
parent 4d2592992c
commit 9609fafe93
No known key found for this signature in database
GPG key ID: 3E2953A359E7E7BD

View file

@ -97,9 +97,11 @@ export default class Dialog extends WithTemplate {
currentZIndex() {
return Math.max(
...Array.from(document.querySelectorAll('dialog')).map(
(el) => window.getComputedStyle(el).getPropertyValue('z-index') || 0
)
...Array.from(document.querySelectorAll('dialog')).map((el) => {
const zIndex = window.getComputedStyle(el).getPropertyValue('z-index')
if (zIndex === 'auto') return 0
return zIndex || 0
})
)
}
@ -127,7 +129,9 @@ export default class Dialog extends WithTemplate {
this.hasFormData = this.elements.fieldset.elements.length > 0
const currentZIndex = this.currentZIndex()
if (currentZIndex) this.dialog.style.zIndex = currentZIndex + 1
if (currentZIndex) {
this.dialog.style.zIndex = currentZIndex + 1
}
this.toggle(true)