Skip to content

Commit

Permalink
slice of null
Browse files Browse the repository at this point in the history
fixing issue ngx-material-keyboard#49, ngx-material-keyboard#50 - null or number input field - function slice()… ngx-material-keyboard#55
  • Loading branch information
slang123 authored May 13, 2018
1 parent b9e750c commit 1023075
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 1023075

Please sign in to comment.