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:form): optimize code to increase robustness #5550

Merged
merged 1 commit into from
Jul 13, 2020
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
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