Skip to content

Commit e343f49

Browse files
committed
Prevent overflowing static backdrop modal animation
1 parent 481f7c6 commit e343f49

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

js/src/modal.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -416,10 +416,24 @@ class Modal {
416416
return
417417
}
418418

419+
const isModalOverflowing =
420+
this._element.scrollHeight > document.documentElement.clientHeight
421+
422+
if (!isModalOverflowing) {
423+
this._element.style.overflowY = 'hidden'
424+
}
425+
419426
this._element.classList.add(ClassName.STATIC)
420-
const modalTransitionDuration = getTransitionDurationFromElement(this._element)
427+
const modalTransitionDuration = getTransitionDurationFromElement(this._dialog)
428+
EventHandler.off(this._element, TRANSITION_END)
421429
EventHandler.one(this._element, TRANSITION_END, () => {
422430
this._element.classList.remove(ClassName.STATIC)
431+
if (!isModalOverflowing) {
432+
EventHandler.one(this._element, TRANSITION_END, () => {
433+
this._element.style.overflowY = ''
434+
})
435+
emulateTransitionEnd(this._element, modalTransitionDuration)
436+
}
423437
})
424438
emulateTransitionEnd(this._element, modalTransitionDuration)
425439
this._element.focus()

0 commit comments

Comments
 (0)