Skip to content

Commit

Permalink
fix(module:form): optimize code to increase robustness (#5550)
Browse files Browse the repository at this point in the history
  • Loading branch information
danranVm authored Jul 13, 2020
1 parent 07d91a1 commit fdf085b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components/form/form-control.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export class NzFormControlComponent implements OnChanges, OnDestroy, OnInit, Aft
for (const key in errors) {
if (errors.hasOwnProperty(key)) {
autoErrorTip =
errors[key][this.localeId] ??
errors[key]?.[this.localeId] ??
this.nzAutoTips?.[this.localeId]?.[key] ??
this.nzFormDirective?.nzAutoTips?.[this.localeId]?.[key];
}
Expand Down
5 changes: 4 additions & 1 deletion components/form/form.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { filter, map } from 'rxjs/operators';

const NZ_CONFIG_COMPONENT_NAME = 'form';

export type NzFormLayoutType = 'horizontal' | 'vertical' | 'inline';

@Directive({
selector: '[nz-form]',
exportAs: 'nzForm',
Expand All @@ -26,7 +28,7 @@ export class NzFormDirective implements OnChanges, OnDestroy, InputObservable {
static ngAcceptInputType_nzNoColon: BooleanInput;
static ngAcceptInputType_nzDisableAutoTips: BooleanInput;

@Input() nzLayout: 'horizontal' | 'vertical' | 'inline' = 'horizontal';
@Input() nzLayout: NzFormLayoutType = 'horizontal';
@Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME) @InputBoolean() nzNoColon: boolean = false;
@Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME) nzAutoTips: Record<string, Record<string, string>> = {};
@Input() @InputBoolean() nzDisableAutoTips = false;
Expand All @@ -50,6 +52,7 @@ export class NzFormDirective implements OnChanges, OnDestroy, InputObservable {
}

ngOnDestroy(): void {
this.inputChanges$.complete();
this.destroy$.next();
this.destroy$.complete();
}
Expand Down

0 comments on commit fdf085b

Please sign in to comment.