diff options
| author | alpadev <[email protected]> | 2021-06-03 13:44:16 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-06-03 14:44:16 +0300 |
| commit | 4a5029ea29ac75243dfec68153051292fc70f5cf (patch) | |
| tree | 7d0a74707b0f1ab8254610a53dcbf92eabae81b4 /js/src/modal.js | |
| parent | 071a288d39f70719c771cd56ded6c36b5d150a83 (diff) | |
| download | bootstrap-4a5029ea29ac75243dfec68153051292fc70f5cf.tar.xz bootstrap-4a5029ea29ac75243dfec68153051292fc70f5cf.zip | |
Fix handling of transitionend events dispatched by nested elements(#33845)
Fix handling of transitionend events dispatched by nested elements
Properly handle events from nested elements
Change `emulateTransitionEnd` to `executeAfterTransition` &&
Diffstat (limited to 'js/src/modal.js')
| -rw-r--r-- | js/src/modal.js | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/js/src/modal.js b/js/src/modal.js index b05fe8de7..e8eee3b4d 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -7,9 +7,7 @@ import { defineJQueryPlugin, - emulateTransitionEnd, getElementFromSelector, - getTransitionDurationFromElement, isRTL, isVisible, reflow, @@ -339,25 +337,28 @@ class Modal extends BaseComponent { return } - const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight + const { classList, scrollHeight, style } = this._element + const isModalOverflowing = scrollHeight > document.documentElement.clientHeight + + // return if the following background transition hasn't yet completed + if ((!isModalOverflowing && style.overflowY === 'hidden') || classList.contains(CLASS_NAME_STATIC)) { + return + } if (!isModalOverflowing) { - this._element.style.overflowY = 'hidden' + style.overflowY = 'hidden' } - this._element.classList.add(CLASS_NAME_STATIC) - const modalTransitionDuration = getTransitionDurationFromElement(this._dialog) - EventHandler.off(this._element, 'transitionend') - EventHandler.one(this._element, 'transitionend', () => { - this._element.classList.remove(CLASS_NAME_STATIC) + classList.add(CLASS_NAME_STATIC) + this._queueCallback(() => { + classList.remove(CLASS_NAME_STATIC) if (!isModalOverflowing) { - EventHandler.one(this._element, 'transitionend', () => { - this._element.style.overflowY = '' - }) - emulateTransitionEnd(this._element, modalTransitionDuration) + this._queueCallback(() => { + style.overflowY = '' + }, this._dialog) } - }) - emulateTransitionEnd(this._element, modalTransitionDuration) + }, this._dialog) + this._element.focus() } |
