From bf7f1c0a7fa9c9e925f334e57b6ba7d4d16d91e2 Mon Sep 17 00:00:00 2001 From: ydock1 Date: Thu, 8 Mar 2018 12:36:39 -0300 Subject: [PATCH] Update keyboard-key.component.ts solved: "value.slice is not a function" <- (when the textbox is empty) Backspace not working --- .../src/components/keyboard-key/keyboard-key.component.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 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 3e893c2b..3efdab38 100644 --- a/src/core/src/components/keyboard-key/keyboard-key.component.ts +++ b/src/core/src/components/keyboard-key/keyboard-key.component.ts @@ -140,9 +140,9 @@ export class MatKeyboardKeyComponent implements OnInit { // Trigger a global key event // TODO: determine whether an output should bubble the pressed key similar to the keybboard action or not this._triggerKeyEvent(); - + // Manipulate the focused input / textarea value - const value = this.inputValue; + const value = this.inputValue == null ? "" : this.inputValue; const caret = this.input ? this._getCursorPosition() : 0; let char: string; @@ -156,7 +156,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); break; @@ -194,7 +194,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); } }