Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(module:modal): buttons cannot disable when confirm mode #3707

Merged
merged 2 commits into from
Jul 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions components/modal/nz-modal.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,20 @@
</div>
</div>
<div class="ant-modal-confirm-btns">
<button nz-button *ngIf="nzCancelText!==null" (click)="onClickOkCancel('cancel')" [nzLoading]="nzCancelLoading">
<button *ngIf="nzCancelText!==null"
nz-button
(click)="onClickOkCancel('cancel')"
[nzLoading]="nzCancelLoading"
[disabled]="nzCancelDisabled">
{{ cancelText }}
</button>
<button *ngIf="nzOkText!==null" #autoFocusButtonOk nz-button [nzType]="nzOkType" (click)="onClickOkCancel('ok')" [nzLoading]="nzOkLoading">
<button #autoFocusButtonOk
*ngIf="nzOkText!==null"
nz-button
(click)="onClickOkCancel('ok')"
[nzType]="nzOkType"
[nzLoading]="nzOkLoading"
[disabled]="nzOkDisabled">
{{ okText }}
</button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion components/modal/nz-modal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class NzModalComponent<T = any, R = any> extends NzModalRef<T, R>
@Input() nzBodyStyle: object;
@Input() nzOkText: string | null;
@Input() nzCancelText: string | null;
@Input() nzOkType = 'primary';
@Input() nzOkType: string = 'primary';
@Input() nzIconType: string = 'question-circle'; // Confirm Modal ONLY
@Input() nzModalType: ModalType = 'default';

Expand Down
18 changes: 18 additions & 0 deletions components/modal/nz-modal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,17 @@ describe('modal testing (legacy)', () => {
ids.forEach(id => expectModalDestroyed(id, false));
}));

it('should disable buttons', fakeAsync(() => {
const modalRef = instance.createDisabledModal();
fixture.detectChanges();
flush();
fixture.detectChanges();
const buttons = modalRef.getElement().querySelectorAll('.ant-modal-confirm-btns button') as NodeListOf<
HTMLButtonElement
>;
buttons.forEach(button => expect(button.disabled).toBe(true));
}));

it('should render content with component', fakeAsync(() => {
const modalRef = instance.createCustomContentWithComponent();
const modalElement = modalRef.getElement();
Expand Down Expand Up @@ -931,6 +942,13 @@ export class TestConfirmModalComponent {
nzContent: TestConfirmCustomComponent
});
}

createDisabledModal(): NzModalRef {
return this.modalService.confirm({
nzCancelDisabled: true,
nzOkDisabled: true
});
}
}

@Component({
Expand Down