fix issue that user is not able to interact with checkbox in declarative table using keyboard (#14863)

* handle space key press

* correct fix
This commit is contained in:
Alan Ren
2021-03-24 19:07:12 -07:00
committed by GitHub
parent 2b7535f377
commit f12c8cd5d3
2 changed files with 4 additions and 10 deletions

View File

@@ -7,7 +7,6 @@ import 'vs/css!./media/checkbox';
import { Color } from 'vs/base/common/color';
import { Event, Emitter } from 'vs/base/common/event';
import { KeyCode } from 'vs/base/common/keyCodes';
import { Widget } from 'vs/base/browser/ui/widget';
export interface ICheckboxOptions {
@@ -45,15 +44,6 @@ export class Checkbox extends Widget {
this._onChange.fire(this.checked);
});
this.onkeydown(this._el, e => {
if (e.equals(KeyCode.Enter)) {
this.checked = !this.checked;
// Manually fire the event since we stop the event propagation which means
// the onchange event won't fire.
this._onChange.fire(this.checked);
e.stopPropagation();
}
});
this._label = document.createElement('span');
this._label.style.verticalAlign = 'middle';

View File

@@ -331,6 +331,10 @@ export default class DeclarativeTableComponent extends ContainerBase<any, azdata
}
public onKey(e: KeyboardEvent, row: number) {
// Ignore the bubble up events
if (e.target !== e.currentTarget) {
return;
}
const event = new StandardKeyboardEvent(e);
if (event.equals(KeyCode.Enter) || event.equals(KeyCode.Space)) {
this.onRowSelected(row);