Skip to content

Commit 1023075

Browse files
authored
slice of null
fixing issue ngx-material-keyboard#49, ngx-material-keyboard#50 - null or number input field - function slice()… ngx-material-keyboard#55
1 parent b9e750c commit 1023075

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/core/src/components/keyboard-key/keyboard-key.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export class MatKeyboardKeyComponent implements OnInit {
162162
this.genericClick.emit(event);
163163

164164
// Manipulate the focused input / textarea value
165-
const value = this.inputValue;
165+
const value = this.inputValue == null ? "" : this.inputValue.toString();
166166
const caret = this.input ? this._getCursorPosition() : 0;
167167

168168
let char: string;
@@ -176,7 +176,7 @@ export class MatKeyboardKeyComponent implements OnInit {
176176
break;
177177

178178
case KeyboardClassKey.Bksp:
179-
this.inputValue = [value.slice(0, caret - 1), value.slice(caret)].join('');
179+
this.inputValue = [value.slice(0, caret - 1)].join('');
180180
this._setCursorPosition(caret - 1);
181181
this.bkspClick.emit(event);
182182
break;
@@ -218,7 +218,7 @@ export class MatKeyboardKeyComponent implements OnInit {
218218
}
219219

220220
if (char && this.input) {
221-
this.inputValue = [value.slice(0, caret), char, value.slice(caret)].join('');
221+
this.inputValue = caret ? [value.slice(0, caret), char, value.slice(caret)].join('') : value + char;
222222
this._setCursorPosition(caret + 1);
223223
}
224224
}

0 commit comments

Comments
 (0)