]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Backport #30326
authorXhmikosR <xhmikosr@gmail.com>
Thu, 25 Jun 2020 12:40:30 +0000 (15:40 +0300)
committerXhmikosR <xhmikosr@gmail.com>
Mon, 6 Jul 2020 13:40:27 +0000 (16:40 +0300)
Prevent overflowing static backdrop modal animation

TODO: backport the test too

js/src/modal.js

index 0a2d99a0322c8e0be7c00df8df8ef9b8864fef27..ec44929f07db4c9cdd13d68dc60dd3c6a7acdace 100644 (file)
@@ -238,12 +238,25 @@ class Modal {
         return
       }
 
+      const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight
+
+      if (!isModalOverflowing) {
+        this._element.style.overflowY = 'hidden'
+      }
+
       this._element.classList.add(CLASS_NAME_STATIC)
 
-      const modalTransitionDuration = Util.getTransitionDurationFromElement(this._element)
+      const modalTransitionDuration = Util.getTransitionDurationFromElement(this._dialog)
+      $(this._element).off(Util.TRANSITION_END)
 
       $(this._element).one(Util.TRANSITION_END, () => {
         this._element.classList.remove(CLASS_NAME_STATIC)
+        if (!isModalOverflowing) {
+          $(this._element).one(Util.TRANSITION_END, () => {
+            this._element.style.overflowY = ''
+          })
+            .emulateTransitionEnd(this._element, modalTransitionDuration)
+        }
       })
         .emulateTransitionEnd(modalTransitionDuration)
       this._element.focus()