From dfa017adc382c63766cd5d021bdc8f6ad1b04932 Mon Sep 17 00:00:00 2001 From: ysds Date: Wed, 4 Mar 2020 23:51:15 +0900 Subject: [PATCH] Always modal scroll top to 0 --- js/src/modal.js | 6 ++---- js/tests/unit/modal.spec.js | 16 ++++++++-------- 2 files changed, 10 insertions(+), 12 deletions(-) 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 = [ '