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

Commit

Permalink
fix(modal): remove window class after animation
Browse files Browse the repository at this point in the history
- Wait until animations are complete before removing window class

BREAKING CHANGE: This introduces a minor behavior change in when the class is removed

Closes #6056
Fixes #6051
  • Loading branch information
Anthony Cleaver authored and wesleycho committed Jun 27, 2016
1 parent ed3400b commit 409b7aa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,16 +375,17 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap', 'ui.bootstrap.p
afterAnimating.done = true;

$animate.leave(domEl).then(function() {
if (done) {
done();
}

domEl.remove();
if (closedDeferred) {
closedDeferred.resolve();
}
});

scope.$destroy();
if (done) {
done();
}
}
}

Expand Down
10 changes: 8 additions & 2 deletions src/modal/test/modal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1390,15 +1390,21 @@ describe('$uibModal', function() {
expect(body).not.toHaveClass('modal-open');
});

it('should remove the custom class on closing of modal', function() {
it('should remove the custom class on closing of modal after animations have completed', function() {
var modal = open({
template: '<div>dummy modal</div>',
openedClass: 'foo'
});

expect(body).toHaveClass('foo');

close(modal);
close(modal, null, true);
expect(body).toHaveClass('foo');

$animate.flush();
$rootScope.$digest();
$animate.flush();
$rootScope.$digest();

expect(body).not.toHaveClass('foo');
});
Expand Down

0 comments on commit 409b7aa

Please sign in to comment.