Skip to content

Commit

Permalink
fix(module:modal): content not work in confirm mode when the type is …
Browse files Browse the repository at this point in the history
…component (#3415)

close #3407
  • Loading branch information
hsuanxyz authored and wenqi73 committed May 17, 2019
1 parent 9d495fc commit 6458c57
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components/modal/nz-modal.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
</ng-container>
</span>
<div class="ant-modal-confirm-content">
<ng-container>
<ng-container #bodyContainer>
<ng-container *ngIf="!isComponent(nzContent)" [ngSwitch]="true">
<ng-container *ngSwitchCase="isTemplateRef(nzContent)" [ngTemplateOutlet]="nzContent"></ng-container>
<ng-container *ngSwitchCase="isNonEmptyString(nzContent)"><div [innerHTML]="nzContent"></div></ng-container>
Expand Down
34 changes: 33 additions & 1 deletion components/modal/nz-modal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,13 @@ describe('modal testing (legacy)', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [NoopAnimationsModule, NzModalModule],
declarations: [TestConfirmModalComponent],
declarations: [TestConfirmModalComponent, TestConfirmCustomComponent],
providers: [NzMeasureScrollbarService]
}).compileComponents();

TestBed.overrideModule(BrowserDynamicTestingModule, {
set: { entryComponents: [TestConfirmCustomComponent] }
}).compileComponents();
}));

beforeEach(() => {
Expand Down Expand Up @@ -315,6 +319,17 @@ describe('modal testing (legacy)', () => {
fixture.detectChanges();
ids.forEach(id => expectModalDestroyed(id, false));
}));

it('should render content with component', fakeAsync(() => {
const modalRef = instance.createCustomContentWithComponent();
const modalElement = modalRef.getElement();
fixture.detectChanges();
expect(modalElement.querySelector('.custom-component-in-confirm')).toBeTruthy();
getButtonOk(modalElement).click();
fixture.detectChanges();
flush();
fixture.detectChanges();
}));
});

describe('css-unit.pipe', () => {
Expand Down Expand Up @@ -865,6 +880,23 @@ export class TestConfirmModalComponent {
return modalId;
});
}

createCustomContentWithComponent(): NzModalRef {
return this.modalService.confirm({
nzContent: TestConfirmCustomComponent
});
}
}

@Component({
template: `
<span class="custom-component-in-confirm">
Content
</span>
`
})
export class TestConfirmCustomComponent {
constructor() {}
}

@Component({
Expand Down

0 comments on commit 6458c57

Please sign in to comment.