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

Commit ba2ce24

Browse files
committed
fix(modal): correctly remove custom class
- Fix removal of custom class on closing/dismissing of modal Closes #4175 Fixes #4171
1 parent ace4ae1 commit ba2ce24

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

src/modal/modal.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ angular.module('ui.bootstrap.modal', [])
272272
openedWindows.remove(modalInstance);
273273

274274
removeAfterAnimate(modalWindow.modalDomEl, modalWindow.modalScope, function() {
275-
body.toggleClass(modalInstance.openedClass || OPENED_MODAL_CLASS, openedWindows.length() > 0);
275+
body.toggleClass(modalWindow.openedClass || OPENED_MODAL_CLASS, openedWindows.length() > 0);
276276
});
277277
checkRemoveBackdrop();
278278

src/modal/test/modal.spec.js

+19-3
Original file line numberDiff line numberDiff line change
@@ -768,13 +768,18 @@ describe('$modal', function () {
768768
});
769769

770770
describe('openedClass', function () {
771+
var body;
772+
773+
beforeEach(function() {
774+
body = $document.find('body');
775+
});
771776

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

777-
expect($document.find('body')).toHaveClass('modal-open');
782+
expect(body).toHaveClass('modal-open');
778783
});
779784

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

786-
var body = $document.find('body');
787-
788791
expect(body).toHaveClass('foo');
789792
expect(body).not.toHaveClass('modal-open');
790793
});
794+
795+
it('should remove the custom class on closing of modal', function () {
796+
var modal = open({
797+
template: '<div>dummy modal</div>',
798+
openedClass: 'foo'
799+
});
800+
801+
expect(body).toHaveClass('foo');
802+
803+
close(modal);
804+
805+
expect(body).not.toHaveClass('foo');
806+
});
791807
});
792808

793809
});

0 commit comments

Comments
 (0)