Skip to content

Commit

Permalink
fix(modal): honor modalWndowClass option
Browse files Browse the repository at this point in the history
fix #4067
  • Loading branch information
jnizet committed Apr 13, 2021
1 parent b27b899 commit 6e970f1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ <h4 class="modal-title">Modal title</h4>
<button class="btn btn-outline-primary mb-2 mr-2" (click)="openXl(content)">Extra large modal</button>
<button class="btn btn-outline-primary mb-2 mr-2" (click)="openVerticallyCentered(content)">Modal vertically centered</button>
<button class="btn btn-outline-primary mb-2 mr-2" (click)="openScrollableContent(longContent)">Modal scrollable content</button>
<button class="btn btn-outline-primary mb-2 mr-2" (click)="openModalDialogCustomClass(content)">Modal with dialog custom class</button>
4 changes: 4 additions & 0 deletions demo/src/app/components/modal/demos/options/modal-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@ export class NgbdModalOptions {
openScrollableContent(longContent) {
this.modalService.open(longContent, { scrollable: true });
}

openModalDialogCustomClass(content) {
this.modalService.open(content, { modalDialogClass: 'dark-modal' });
}
}
2 changes: 1 addition & 1 deletion src/modal/modal-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class NgbModalStack {
private _modalRefs: NgbModalRef[] = [];
private _windowAttributes = [
'animation', 'ariaLabelledBy', 'ariaDescribedBy', 'backdrop', 'centered', 'keyboard', 'scrollable', 'size',
'windowClass'
'windowClass', 'modalDialogClass'
];
private _windowCmpts: ComponentRef<NgbModalWindow>[] = [];
private _activeInstances: EventEmitter<NgbModalRef[]> = new EventEmitter();
Expand Down
15 changes: 15 additions & 0 deletions src/modal/modal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,21 @@ describe('ngb-modal', () => {

});

describe('modal dialog custom class options', () => {

it('should render modals with the correct dialog custom classes', () => {
const modalInstance = fixture.componentInstance.open('foo', {modalDialogClass: 'bar'});
fixture.detectChanges();
expect(fixture.nativeElement).toHaveModal('foo');
expect(document.querySelector('.modal-dialog')).toHaveCssClass('bar');

modalInstance.close();
fixture.detectChanges();
expect(fixture.nativeElement).not.toHaveModal();
});

});

describe('custom injector option', () => {

it('should render modal with a custom injector', () => {
Expand Down

0 comments on commit 6e970f1

Please sign in to comment.