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

fix(modal): correctly remove custom class #4175

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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