Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update keyboard-key.component.ts #51

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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);
}
}
Expand Down