Skip to content

Commit

Permalink
fix(module:modal): nzAutofocus doesn't work correctly (#5313)
Browse files Browse the repository at this point in the history
Co-authored-by: rorry <luolei@haizhi.com>
  • Loading branch information
rorry121 and rorry authored May 25, 2020
1 parent e13142c commit 7ad64b8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions components/modal/modal-confirm-container.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import { ModalOptions } from './modal-types';
<div class="ant-modal-confirm-btns">
<button
*ngIf="config.nzCancelText !== null"
[attr.cdkFocusInitial]="config.nzAutofocus === 'cancel'"
[attr.cdkFocusInitial]="config.nzAutofocus === 'cancel' || null"
nz-button
(click)="onCancel()"
[nzLoading]="!!config.nzCancelLoading"
Expand All @@ -76,7 +76,7 @@ import { ModalOptions } from './modal-types';
</button>
<button
*ngIf="config.nzOkText !== null"
[attr.cdkFocusInitial]="config.nzAutofocus === 'ok'"
[attr.cdkFocusInitial]="config.nzAutofocus === 'ok' || null"
nz-button
[nzType]="config.nzOkType!"
(click)="onOk()"
Expand Down
4 changes: 2 additions & 2 deletions components/modal/modal-footer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import { ModalButtonOptions, ModalOptions } from './modal-types';
<ng-template #defaultFooterButtons>
<button
*ngIf="config.nzCancelText !== null"
[attr.cdkFocusInitial]="config.nzAutofocus === 'cancel'"
[attr.cdkFocusInitial]="config.nzAutofocus === 'cancel' || null"
nz-button
(click)="onCancel()"
[nzLoading]="!!config.nzCancelLoading"
Expand All @@ -54,7 +54,7 @@ import { ModalButtonOptions, ModalOptions } from './modal-types';
</button>
<button
*ngIf="config.nzOkText !== null"
[attr.cdkFocusInitial]="config.nzAutofocus === 'ok'"
[attr.cdkFocusInitial]="config.nzAutofocus === 'ok' || null"
nz-button
[nzType]="config.nzOkType!"
(click)="onOk()"
Expand Down
1 change: 1 addition & 0 deletions components/modal/modal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export class NzModalComponent<T = NzSafeAny, R = NzSafeAny> implements OnChanges
@Input() nzOkType: NzButtonType = 'primary';
@Input() nzIconType: string = 'question-circle'; // Confirm Modal ONLY
@Input() nzModalType: ModalTypes = 'default';
@Input() nzAutofocus: 'ok' | 'cancel' | 'auto' | null = 'auto';

// TODO(@hsuanxyz) Input will not be supported
@Input()
Expand Down
6 changes: 4 additions & 2 deletions components/modal/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export function getConfigFromComponent(component: NzModalComponent): ModalOption
nzOnCancel,
nzAfterOpen,
nzAfterClose,
nzCloseOnNavigation
nzCloseOnNavigation,
nzAutofocus
} = component;
return {
nzMask,
Expand Down Expand Up @@ -93,6 +94,7 @@ export function getConfigFromComponent(component: NzModalComponent): ModalOption
nzOnCancel,
nzAfterOpen,
nzAfterClose,
nzCloseOnNavigation
nzCloseOnNavigation,
nzAutofocus
};
}

0 comments on commit 7ad64b8

Please sign in to comment.