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

Commit

Permalink
fix(modal): fix race condition with openedClass
Browse files Browse the repository at this point in the history
- Fixes race condition with modal if it is closed before animation is complete

Closes #5483
  • Loading branch information
Tuomo Jokimies authored and wesleycho committed Feb 16, 2016
1 parent 57326a9 commit 979fe0b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/modal/modal.js
Expand Up @@ -479,7 +479,9 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap'])

$animate.enter($compile(angularDomEl)(modal.scope), appendToElement)
.then(function() {
$animate.addClass(appendToElement, modalBodyClass);
if (!modal.scope.$$uibDestructionScheduled) {
$animate.addClass(appendToElement, modalBodyClass);
}
});

openedWindows.top().value.modalDomEl = angularDomEl;
Expand Down
10 changes: 10 additions & 0 deletions src/modal/test/modal.spec.js
Expand Up @@ -1219,6 +1219,16 @@ describe('$uibModal', function() {
expect(body).not.toHaveClass('bar');
expect(body).not.toHaveClass('modal-open');
});

it('should not add the modal-open class if modal is closed before animation', function() {
var modal = open({
template: '<div>dummy modal</div>'
}, true);

close(modal);

expect(body).not.toHaveClass('modal-open');
});
});
});

Expand Down

0 comments on commit 979fe0b

Please sign in to comment.