diff --git a/js/src/modal.js b/js/src/modal.js index ca77359cabd4..d5f1c8c9ae99 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -60,7 +60,6 @@ const EVENT_MOUSEUP_DISMISS = `mouseup.dismiss${EVENT_KEY}` const EVENT_MOUSEDOWN_DISMISS = `mousedown.dismiss${EVENT_KEY}` const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}` -const CLASS_NAME_SCROLLABLE = 'modal-dialog-scrollable' const CLASS_NAME_SCROLLBAR_MEASURER = 'modal-scrollbar-measure' const CLASS_NAME_BACKDROP = 'modal-backdrop' const CLASS_NAME_OPEN = 'modal-open' @@ -249,11 +248,10 @@ class Modal { this._element.style.display = 'block' this._element.removeAttribute('aria-hidden') this._element.setAttribute('aria-modal', true) + this._element.scrollTop = 0 - if (this._dialog.classList.contains(CLASS_NAME_SCROLLABLE) && modalBody) { + if (modalBody) { modalBody.scrollTop = 0 - } else { - this._element.scrollTop = 0 } if (transition) { diff --git a/js/tests/unit/modal.spec.js b/js/tests/unit/modal.spec.js index c5fbc3a27392..52676844f4a8 100644 --- a/js/tests/unit/modal.spec.js +++ b/js/tests/unit/modal.spec.js @@ -382,40 +382,40 @@ describe('Modal', () => { modal.show() }) - it('should set modal body scroll top to 0 if .modal-dialog-scrollable', done => { + it('should set .modal\'s scroll top to 0', done => { fixtureEl.innerHTML = [ '