Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit ea18f49

Browse files
authored
fix(text-field): Should clear ngModel when empty (#940)
Also, fixes pre-filled data setting form dirty. Closes #939 Closes #940
1 parent f899d07 commit ea18f49

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/lib/textfield/text-field.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ export class MdcTextField implements AfterViewInit, AfterContentInit, OnDestroy,
378378
}
379379

380380
writeValue(value: any): void {
381-
this.setValue(value == null ? '' : value);
381+
this.setValue(value == null ? '' : value, false);
382382
this._changeDetectorRef.markForCheck();
383383
}
384384

@@ -444,12 +444,12 @@ export class MdcTextField implements AfterViewInit, AfterContentInit, OnDestroy,
444444
this._changeDetectorRef.markForCheck();
445445
}
446446

447-
setValue(value: any): void {
447+
setValue(value: any, isUserInput: boolean = true): void {
448448
this._value = (this.type === 'number') ?
449449
(value === '' ? null : toNumber(value)) : value;
450450

451451
this._foundation.setValue(this.value);
452-
if (this.value) {
452+
if (isUserInput) {
453453
this._onChange(this.value);
454454
}
455455

0 commit comments

Comments
 (0)