checkbox/find: do not move focus when checkbox interaction via keyboard

This commit is contained in:
Benjamin Pasero
2016-02-02 12:30:14 +01:00
parent be5a478440
commit 82d1a0b77c
3 changed files with 30 additions and 20 deletions

View File

@@ -17,7 +17,7 @@ export interface ICheckboxOpts {
actionClassName: string;
title: string;
isChecked: boolean;
onChange: () => void;
onChange: (viaKeyboard: boolean) => void;
onKeyDown?: (e: StandardKeyboardEvent) => void;
}
@@ -43,14 +43,14 @@ export class Checkbox extends Widget {
this.onclick(this.domNode, (ev) => {
this.checked = !this._checked;
this._opts.onChange();
this._opts.onChange(false);
ev.preventDefault();
});
this.onkeydown(this.domNode, (keyboardEvent) => {
if (keyboardEvent.keyCode === KeyCode.Space || keyboardEvent.keyCode === KeyCode.Enter) {
this.checked = !this._checked;
this._opts.onChange();
this._opts.onChange(true);
keyboardEvent.preventDefault();
return;
}