Skip to content

Commit

Permalink
fix(modal): restore backdrop: false functionality
Browse files Browse the repository at this point in the history
Fixes #989

Closes #990
  • Loading branch information
pkozlowski-opensource committed Nov 2, 2016
1 parent a6ec937 commit 0e2f386
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/modal/modal-container.ts
Expand Up @@ -40,12 +40,11 @@ export class NgbModalContainer {
let ngbModalRef: NgbModalRef;

if (options.backdrop !== false) {
backdropCmptRef =
this._viewContainerRef.createComponent(this._backdropFactory, this._viewContainerRef.length, this._injector);
backdropCmptRef = this._viewContainerRef.createComponent(this._backdropFactory, 0, this._injector);
}

windowCmptRef = this._viewContainerRef.createComponent(
this._windowFactory, this._viewContainerRef.length, this._injector, contentRef.nodes);
this._windowFactory, this._viewContainerRef.length - 1, this._injector, contentRef.nodes);

ngbModalRef = new NgbModalRef(this._viewContainerRef, windowCmptRef, contentRef, backdropCmptRef);

Expand Down
14 changes: 14 additions & 0 deletions src/modal/modal.spec.ts
Expand Up @@ -256,6 +256,20 @@ describe('ngb-modal', () => {
expect(fixture.nativeElement).not.toHaveBackdrop();
});

it('should open and close modal without backdrop from template content', () => {
const modalInstance = fixture.componentInstance.openTpl({backdrop: false});
fixture.detectChanges();

expect(fixture.nativeElement).toHaveModal('Hello, World!');
expect(fixture.nativeElement).not.toHaveBackdrop();

modalInstance.close('some reason');
fixture.detectChanges();

expect(fixture.nativeElement).not.toHaveModal();
expect(fixture.nativeElement).not.toHaveBackdrop();
});

it('should dismiss on backdrop click', () => {
fixture.componentInstance.open('foo').result.catch(NOOP);
fixture.detectChanges();
Expand Down

0 comments on commit 0e2f386

Please sign in to comment.