1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-10-01 15:56:45 +02:00
allow dynamic modal body for scrollable modals
This commit is contained in:
Johann-S
2019-07-28 12:19:00 +02:00
committed by XhmikosR
parent 8f95b26d65
commit e4d4c5d0bc
2 changed files with 24 additions and 2 deletions

View File

@@ -236,6 +236,7 @@ class Modal {
_showElement(relatedTarget) {
const transition = $(this._element).hasClass(ClassName.FADE)
const modalBody = this._dialog ? this._dialog.querySelector(Selector.MODAL_BODY) : null
if (!this._element.parentNode ||
this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
@@ -247,8 +248,8 @@ class Modal {
this._element.removeAttribute('aria-hidden')
this._element.setAttribute('aria-modal', true)
if ($(this._dialog).hasClass(ClassName.SCROLLABLE)) {
this._dialog.querySelector(Selector.MODAL_BODY).scrollTop = 0
if ($(this._dialog).hasClass(ClassName.SCROLLABLE) && modalBody) {
modalBody.scrollTop = 0
} else {
this._element.scrollTop = 0
}