Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit aef08d5

Browse files
RobJacobsdeeg
authored andcommitted
fix(modal): scroll padding only added once
- Ensure the scroll padding meant to offset the modal-open class only gets added once when mulitple modal windows are open. Closes #5790 Fixes #5789
1 parent a27a4e2 commit aef08d5

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/modal/modal.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,9 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap', 'ui.bootstrap.p
309309
removeAfterAnimate(modalWindow.modalDomEl, modalWindow.modalScope, function() {
310310
var modalBodyClass = modalWindow.openedClass || OPENED_MODAL_CLASS;
311311
openedClasses.remove(modalBodyClass, modalInstance);
312-
appendToElement.toggleClass(modalBodyClass, openedClasses.hasKey(modalBodyClass));
313-
if (scrollbarPadding && scrollbarPadding.heightOverflow && scrollbarPadding.scrollbarWidth) {
312+
var areAnyOpen = openedClasses.hasKey(modalBodyClass);
313+
appendToElement.toggleClass(modalBodyClass, areAnyOpen);
314+
if (!areAnyOpen && scrollbarPadding && scrollbarPadding.heightOverflow && scrollbarPadding.scrollbarWidth) {
314315
if (scrollbarPadding.originalRight) {
315316
appendToElement.css({paddingRight: scrollbarPadding.originalRight + 'px'});
316317
} else {
@@ -444,7 +445,7 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap', 'ui.bootstrap.p
444445
modalBodyClass = modal.openedClass || OPENED_MODAL_CLASS;
445446

446447
toggleTopWindowClass(false);
447-
448+
448449
// Store the current top first, to determine what index we ought to use
449450
// for the current top modal
450451
previousTopOpenedModal = openedWindows.top();
@@ -482,6 +483,10 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap', 'ui.bootstrap.p
482483
}
483484
$compile(backdropDomEl)(backdropScope);
484485
$animate.enter(backdropDomEl, appendToElement);
486+
scrollbarPadding = $uibPosition.scrollbarPadding(appendToElement);
487+
if (scrollbarPadding.heightOverflow && scrollbarPadding.scrollbarWidth) {
488+
appendToElement.css({paddingRight: scrollbarPadding.right + 'px'});
489+
}
485490
}
486491

487492
// Set the top modal index based on the index of the previous top modal
@@ -499,10 +504,6 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap', 'ui.bootstrap.p
499504
angularDomEl.attr('modal-animation', 'true');
500505
}
501506

502-
scrollbarPadding = $uibPosition.scrollbarPadding(appendToElement);
503-
if (scrollbarPadding.heightOverflow && scrollbarPadding.scrollbarWidth) {
504-
appendToElement.css({paddingRight: scrollbarPadding.right + 'px'});
505-
}
506507
appendToElement.addClass(modalBodyClass);
507508
$animate.enter($compile(angularDomEl)(modal.scope), appendToElement);
508509

0 commit comments

Comments
 (0)