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

Commit

Permalink
fix(modal): correctly remove custom class
Browse files Browse the repository at this point in the history
- Fix removal of custom class on closing/dismissing of modal

Closes #4175
Fixes #4171
  • Loading branch information
wesleycho committed Aug 10, 2015
1 parent ace4ae1 commit ba2ce24
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ angular.module('ui.bootstrap.modal', [])
openedWindows.remove(modalInstance);

removeAfterAnimate(modalWindow.modalDomEl, modalWindow.modalScope, function() {
body.toggleClass(modalInstance.openedClass || OPENED_MODAL_CLASS, openedWindows.length() > 0);
body.toggleClass(modalWindow.openedClass || OPENED_MODAL_CLASS, openedWindows.length() > 0);
});
checkRemoveBackdrop();

Expand Down
22 changes: 19 additions & 3 deletions src/modal/test/modal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -768,13 +768,18 @@ describe('$modal', function () {
});

describe('openedClass', function () {
var body;

beforeEach(function() {
body = $document.find('body');
});

it('should add the modal-open class to the body element by default', function () {
open({
template: '<div>dummy modal</div>'
});

expect($document.find('body')).toHaveClass('modal-open');
expect(body).toHaveClass('modal-open');
});

it('should add the custom class to the body element', function () {
Expand All @@ -783,11 +788,22 @@ describe('$modal', function () {
openedClass: 'foo'
});

var body = $document.find('body');

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

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

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

close(modal);

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

});
Expand Down

0 comments on commit ba2ce24

Please sign in to comment.