From f92be2a9257b57675850eb2414fe3624ce856aad Mon Sep 17 00:00:00 2001 From: Miles Malerba Date: Thu, 22 Dec 2016 16:57:09 -0800 Subject: [PATCH] fix(input): fix placeholder for number input with bad input. --- src/lib/input/input-container.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/lib/input/input-container.ts b/src/lib/input/input-container.ts index 37d18f2ff0db..06822a7fd606 100644 --- a/src/lib/input/input-container.ts +++ b/src/lib/input/input-container.ts @@ -124,7 +124,21 @@ export class MdInputDirective implements AfterContentInit { */ @Output() _placeholderChange = new EventEmitter(); - get empty() { return (this.value == null || this.value === '') && !this._isNeverEmpty(); } + get empty() { + if (this._isNeverEmpty()) { + return false; + } + if (this.value == null || this.value === '') { + // Check if this is an element that contains bad input. + // If so, we know that it only appears empty because the value failed to parse. + if (this._elementRef.nativeElement instanceof HTMLInputElement && + this._elementRef.nativeElement.validity.badInput) { + return false; + } + return true; + } + return false; + } focused = false;