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

Commit 839c26b

Browse files
authored
fix(text-field): Should display and float [value] (#1652)
Fixes #1651
1 parent 4739f45 commit 839c26b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/textfield/text-field.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ export class MdcTextField extends _MdcTextFieldMixinBase implements AfterViewIni
237237
get value(): any { return this._value; }
238238
set value(newValue: any) {
239239
if (!this._initialized) {
240-
this._initializeValue();
240+
this.ngControl ? this._initializeValue() : this._initializeValue(newValue);
241241
} else {
242242
this.setValue(newValue, true);
243243
}
@@ -289,7 +289,7 @@ export class MdcTextField extends _MdcTextFieldMixinBase implements AfterViewIni
289289
getNativeInput: () => {
290290
return {
291291
type: this._type,
292-
value: this._value,
292+
value: this._platform.isBrowser ? this._input.nativeElement.value : this._value,
293293
disabled: this._disabled,
294294
validity: {
295295
valid: this._hasErrorState(),
@@ -464,11 +464,11 @@ export class MdcTextField extends _MdcTextFieldMixinBase implements AfterViewIni
464464
this._onTouched = fn;
465465
}
466466

467-
private _initializeValue(): void {
467+
private _initializeValue(value?: any): void {
468468
// Defer setting the value in order to avoid the "Expression
469469
// has changed after it was checked" errors from Angular.
470470
Promise.resolve().then(() => {
471-
this.setValue(this.ngControl ? this.ngControl.value : this._value);
471+
this.setValue(this.ngControl ? this.ngControl.value : value);
472472
});
473473
}
474474

@@ -482,7 +482,7 @@ export class MdcTextField extends _MdcTextFieldMixinBase implements AfterViewIni
482482
return;
483483
}
484484

485-
this._value = newValue ? newValue : null;
485+
this._value = newValue !== undefined ? newValue : null;
486486
if (this._getInputElement().value !== this._value) {
487487
this._getInputElement().value = this._value;
488488
}

0 commit comments

Comments
 (0)