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

Add keybindings to toggle the tree checkbox #13271

Merged
merged 1 commit into from
Jan 16, 2024
Merged
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
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
Loading