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

Commit e55c2de

Browse files
fix(modal): correctly close modals with no backdrop
backdropDomEl was not initialised if only modal without backdrop was opened. Closes #974 Closes #979
1 parent 08d8b21 commit e55c2de

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/modal/modal.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ angular.module('ui.bootstrap.modal', [])
136136
modalWindow.modalDomEl.remove();
137137

138138
//remove backdrop if no longer needed
139-
if (backdropIndex() == -1) {
139+
if (backdropDomEl && backdropIndex() == -1) {
140140
backdropDomEl.remove();
141141
backdropDomEl = undefined;
142142
}
@@ -312,4 +312,4 @@ angular.module('ui.bootstrap.modal', [])
312312
};
313313

314314
return $modalProvider;
315-
});
315+
});

src/modal/test/modal.spec.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -351,12 +351,15 @@ describe('$modal', function () {
351351
describe('backdrop', function () {
352352

353353
it('should not have any backdrop element if backdrop set to false', function () {
354-
open({
354+
var modal =open({
355355
template: '<div>No backdrop</div>',
356356
backdrop: false
357357
});
358358
expect($document).toHaveModalOpenWithContent('No backdrop', 'div');
359359
expect($document).not.toHaveBackdrop();
360+
361+
dismiss(modal);
362+
expect($document).toHaveModalsOpen(0);
360363
});
361364

362365
it('should not close modal on backdrop click if backdrop is specified as "static"', function () {

0 commit comments

Comments
 (0)