From 102307558f4f13199e98617d6a282b42e3ddd9db Mon Sep 17 00:00:00 2001 From: Tummas Joensen Date: Sun, 13 May 2018 21:44:33 +0100 Subject: [PATCH] slice of null MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixing issue #49, #50 - null or number input field - function slice()… #55 --- .../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..5913b65f 100644 --- a/src/core/src/components/keyboard-key/keyboard-key.component.ts +++ b/src/core/src/components/keyboard-key/keyboard-key.component.ts @@ -162,7 +162,7 @@ export class MatKeyboardKeyComponent implements OnInit { this.genericClick.emit(event); // Manipulate the focused input / textarea value - const value = this.inputValue; + const value = this.inputValue == null ? "" : this.inputValue.toString(); const caret = this.input ? this._getCursorPosition() : 0; let char: string; @@ -176,7 +176,7 @@ export class MatKeyboardKeyComponent implements OnInit { break; case KeyboardClassKey.Bksp: - this.inputValue = [value.slice(0, caret - 1), value.slice(caret)].join(''); + this.inputValue = [value.slice(0, caret - 1)].join(''); this._setCursorPosition(caret - 1); this.bkspClick.emit(event); break; @@ -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); } }