From ff4ec3bfed7a501bb4a3635ab5158286620faa44 Mon Sep 17 00:00:00 2001 From: Nikita Barsukov Date: Tue, 14 Jan 2025 17:17:30 +0300 Subject: [PATCH] fix(kit,legacy): all textfield controls should handle initial `ngModel` phantom `null` value --- .../input-phone-international.component.ts | 4 ++-- projects/legacy/components/input-date/input-date.component.ts | 2 +- .../legacy/components/input-phone/input-phone.component.ts | 2 +- projects/legacy/components/input-time/input-time.component.ts | 2 +- projects/legacy/components/input-year/input-year.component.ts | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/projects/kit/components/input-phone-international/input-phone-international.component.ts b/projects/kit/components/input-phone-international/input-phone-international.component.ts index 9627e42c5cb3..2845121eaa56 100644 --- a/projects/kit/components/input-phone-international/input-phone-international.component.ts +++ b/projects/kit/components/input-phone-international/input-phone-international.component.ts @@ -201,8 +201,8 @@ export class TuiInputPhoneInternational extends TuiControl { const maskOptions = this.mask(); this.textfieldValue = maskOptions - ? maskitoTransform(unmaskedValue, maskOptions) - : unmaskedValue; // it will be calibrated later when mask is ready (by maskitoInitialCalibrationPlugin) + ? maskitoTransform(this.value(), maskOptions) + : this.value(); // it will be calibrated later when mask is ready (by maskitoInitialCalibrationPlugin) this.cdr.detectChanges(); } diff --git a/projects/legacy/components/input-date/input-date.component.ts b/projects/legacy/components/input-date/input-date.component.ts index 11ad73c07490..66cbf8ae58ea 100644 --- a/projects/legacy/components/input-date/input-date.component.ts +++ b/projects/legacy/components/input-date/input-date.component.ts @@ -184,7 +184,7 @@ export class TuiInputDateComponent public override writeValue(value: TuiDay | null): void { super.writeValue(value); - this.nativeValue.set(value ? this.computedValue : ''); + this.nativeValue.set(this.value ? this.computedValue : ''); } protected get size(): TuiSizeL | TuiSizeS { diff --git a/projects/legacy/components/input-phone/input-phone.component.ts b/projects/legacy/components/input-phone/input-phone.component.ts index d1a53c8098fe..035f7c7abec4 100644 --- a/projects/legacy/components/input-phone/input-phone.component.ts +++ b/projects/legacy/components/input-phone/input-phone.component.ts @@ -161,7 +161,7 @@ export class TuiInputPhoneComponent public override writeValue(value: string | null): void { super.writeValue(value); - this.nativeValue = maskitoTransform(value || '', this.maskOptions); + this.nativeValue = maskitoTransform(this.value || '', this.maskOptions); this.updateSearch(''); } diff --git a/projects/legacy/components/input-time/input-time.component.ts b/projects/legacy/components/input-time/input-time.component.ts index b581574f0aaa..c048dce84722 100644 --- a/projects/legacy/components/input-time/input-time.component.ts +++ b/projects/legacy/components/input-time/input-time.component.ts @@ -139,7 +139,7 @@ export class TuiInputTimeComponent public override writeValue(value: TuiTime | null): void { super.writeValue(value); - this.nativeValue = value ? this.computedValue : ''; + this.nativeValue = this.value ? this.computedValue : ''; } public onValueChange(value: string): void { diff --git a/projects/legacy/components/input-year/input-year.component.ts b/projects/legacy/components/input-year/input-year.component.ts index a7c2848881cb..4b5540fabd2b 100644 --- a/projects/legacy/components/input-year/input-year.component.ts +++ b/projects/legacy/components/input-year/input-year.component.ts @@ -74,7 +74,7 @@ export class TuiInputYearComponent public override writeValue(value: number | null): void { super.writeValue(value); - this.updateNativeValue(value); + this.updateNativeValue(this.value); } protected get size(): TuiSizeL | TuiSizeS {