From caa8a559e03ae100036e6f5797a6eb490b87e2a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Manuel=20Bermudo?= Date: Wed, 28 Feb 2018 17:55:33 +0100 Subject: [PATCH] fixed input number value --- .../src/components/keyboard-key/keyboard-key.component.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/src/components/keyboard-key/keyboard-key.component.ts b/src/core/src/components/keyboard-key/keyboard-key.component.ts index bb746464..bda41258 100644 --- a/src/core/src/components/keyboard-key/keyboard-key.component.ts +++ b/src/core/src/components/keyboard-key/keyboard-key.component.ts @@ -164,7 +164,7 @@ export class MatKeyboardKeyComponent implements OnInit { // Manipulate the focused input / textarea value const value = this.inputValue; const caret = this.input ? this._getCursorPosition() : 0; - + let char: string; switch (this.key) { // this keys have no actions yet @@ -218,7 +218,7 @@ export class MatKeyboardKeyComponent implements OnInit { } if (char && this.input) { - this.inputValue = [value.slice(0, caret), char, value.slice(caret)].join(''); + this.inputValue = caret ? [value.slice(0, caret), char, value.slice(caret)].join('') : value + char; this._setCursorPosition(caret + 1); } } @@ -272,7 +272,7 @@ export class MatKeyboardKeyComponent implements OnInit { return; } - this.inputValue = this.control.value; + this.inputValue = this.control ? this.control.value : this.inputValue; // ^ this is used to not only get "focus", but // to make sure we don't have it everything -selected- // (it causes an issue in chrome, and having it doesn't hurt any other browser)