Skip to content

Commit bc37818

Browse files
committed
Backport #30326
Prevent overflowing static backdrop modal animation TODO: backport the test too
1 parent 671c95b commit bc37818

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

js/src/modal.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,25 @@ class Modal {
238238
return
239239
}
240240

241+
const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight
242+
243+
if (!isModalOverflowing) {
244+
this._element.style.overflowY = 'hidden'
245+
}
246+
241247
this._element.classList.add(CLASS_NAME_STATIC)
242248

243-
const modalTransitionDuration = Util.getTransitionDurationFromElement(this._element)
249+
const modalTransitionDuration = Util.getTransitionDurationFromElement(this._dialog)
250+
$(this._element).off(Util.TRANSITION_END)
244251

245252
$(this._element).one(Util.TRANSITION_END, () => {
246253
this._element.classList.remove(CLASS_NAME_STATIC)
254+
if (!isModalOverflowing) {
255+
$(this._element).one(Util.TRANSITION_END, () => {
256+
this._element.style.overflowY = ''
257+
})
258+
.emulateTransitionEnd(this._element, modalTransitionDuration)
259+
}
247260
})
248261
.emulateTransitionEnd(modalTransitionDuration)
249262
this._element.focus()

0 commit comments

Comments
 (0)