Skip to content

Commit

Permalink
Backport #30326
Browse files Browse the repository at this point in the history
Prevent overflowing static backdrop modal animation

TODO: backport the test too
  • Loading branch information
XhmikosR committed Jun 25, 2020
1 parent 671c95b commit bc37818
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion js/src/modal.js
Expand Up @@ -238,12 +238,25 @@ class Modal {
return
}

const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight

if (!isModalOverflowing) {
this._element.style.overflowY = 'hidden'
}

this._element.classList.add(CLASS_NAME_STATIC)

const modalTransitionDuration = Util.getTransitionDurationFromElement(this._element)
const modalTransitionDuration = Util.getTransitionDurationFromElement(this._dialog)
$(this._element).off(Util.TRANSITION_END)

$(this._element).one(Util.TRANSITION_END, () => {
this._element.classList.remove(CLASS_NAME_STATIC)
if (!isModalOverflowing) {
$(this._element).one(Util.TRANSITION_END, () => {
this._element.style.overflowY = ''
})
.emulateTransitionEnd(this._element, modalTransitionDuration)
}
})
.emulateTransitionEnd(modalTransitionDuration)
this._element.focus()
Expand Down

0 comments on commit bc37818

Please sign in to comment.