Skip to content

Commit

Permalink
Add keybindings to toggle the tree checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
haydar-metin committed Jan 15, 2024
1 parent f7e2ef9 commit ce92f0e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/core/src/browser/tree/tree-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1227,12 +1227,15 @@ export class TreeWidget extends ReactWidget implements StatefulWidget {

/**
* Handle the `space key` keyboard event.
* - By default should be similar to a single-click action.
* - If the element has a checkbox, it will be toggled.
* - Otherwise, it should be similar to a single-click action.
* @param event the `space key` keyboard event.
*/
protected handleSpace(event: KeyboardEvent): void {
const { focusedNode } = this.focusService;
if (!this.props.multiSelect || (!event.ctrlKey && !event.metaKey && !event.shiftKey)) {
if (focusedNode && focusedNode.checkboxInfo) {
this.model.markAsChecked(focusedNode, !focusedNode.checkboxInfo.checked);
} else if (!this.props.multiSelect || (!event.ctrlKey && !event.metaKey && !event.shiftKey)) {
this.tapNode(focusedNode);
}
}
Expand Down

0 comments on commit ce92f0e

Please sign in to comment.