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

Commit 979fe0b

Browse files
Tuomo Jokimieswesleycho
Tuomo Jokimies
authored andcommitted
fix(modal): fix race condition with openedClass
- Fixes race condition with modal if it is closed before animation is complete Closes #5483
1 parent 57326a9 commit 979fe0b

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Diff for: src/modal/modal.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,9 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap'])
479479

480480
$animate.enter($compile(angularDomEl)(modal.scope), appendToElement)
481481
.then(function() {
482-
$animate.addClass(appendToElement, modalBodyClass);
482+
if (!modal.scope.$$uibDestructionScheduled) {
483+
$animate.addClass(appendToElement, modalBodyClass);
484+
}
483485
});
484486

485487
openedWindows.top().value.modalDomEl = angularDomEl;

Diff for: src/modal/test/modal.spec.js

+10
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,16 @@ describe('$uibModal', function() {
12191219
expect(body).not.toHaveClass('bar');
12201220
expect(body).not.toHaveClass('modal-open');
12211221
});
1222+
1223+
it('should not add the modal-open class if modal is closed before animation', function() {
1224+
var modal = open({
1225+
template: '<div>dummy modal</div>'
1226+
}, true);
1227+
1228+
close(modal);
1229+
1230+
expect(body).not.toHaveClass('modal-open');
1231+
});
12221232
});
12231233
});
12241234

0 commit comments

Comments
 (0)