mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
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:
@@ -7,7 +7,6 @@ import 'vs/css!./media/checkbox';
|
|||||||
|
|
||||||
import { Color } from 'vs/base/common/color';
|
import { Color } from 'vs/base/common/color';
|
||||||
import { Event, Emitter } from 'vs/base/common/event';
|
import { Event, Emitter } from 'vs/base/common/event';
|
||||||
import { KeyCode } from 'vs/base/common/keyCodes';
|
|
||||||
import { Widget } from 'vs/base/browser/ui/widget';
|
import { Widget } from 'vs/base/browser/ui/widget';
|
||||||
|
|
||||||
export interface ICheckboxOptions {
|
export interface ICheckboxOptions {
|
||||||
@@ -45,15 +44,6 @@ export class Checkbox extends Widget {
|
|||||||
this._onChange.fire(this.checked);
|
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 = document.createElement('span');
|
||||||
this._label.style.verticalAlign = 'middle';
|
this._label.style.verticalAlign = 'middle';
|
||||||
|
|||||||
@@ -331,6 +331,10 @@ export default class DeclarativeTableComponent extends ContainerBase<any, azdata
|
|||||||
}
|
}
|
||||||
|
|
||||||
public onKey(e: KeyboardEvent, row: number) {
|
public onKey(e: KeyboardEvent, row: number) {
|
||||||
|
// Ignore the bubble up events
|
||||||
|
if (e.target !== e.currentTarget) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const event = new StandardKeyboardEvent(e);
|
const event = new StandardKeyboardEvent(e);
|
||||||
if (event.equals(KeyCode.Enter) || event.equals(KeyCode.Space)) {
|
if (event.equals(KeyCode.Enter) || event.equals(KeyCode.Space)) {
|
||||||
this.onRowSelected(row);
|
this.onRowSelected(row);
|
||||||
|
|||||||
Reference in New Issue
Block a user