Skip to content

feat(tree): multi-selection no longer requires holding shift key #3733

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

Merged
Merged
Show file tree
Hide file tree
Changes from 13 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
15 changes: 11 additions & 4 deletions src/components/calcite-tree-item/calcite-tree-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export class CalciteTreeItem implements ConditionalSlotComponent {
}
this.calciteTreeItemSelect.emit({
modifyCurrentSelection:
(e as any).shiftKey || this.selectionMode === TreeSelectionMode.Ancestors,
this.selectionMode === TreeSelectionMode.Ancestors || this.isSelectionMulti(),
forceToggle: false
});
}
Expand All @@ -256,7 +256,7 @@ export class CalciteTreeItem implements ConditionalSlotComponent {
this.expanded = !this.expanded;
if (this.selectionMode !== TreeSelectionMode.Ancestors) {
this.calciteTreeItemSelect.emit({
modifyCurrentSelection: event.shiftKey,
modifyCurrentSelection: this.isSelectionMulti(),
forceToggle: true
});
}
Expand All @@ -270,7 +270,7 @@ export class CalciteTreeItem implements ConditionalSlotComponent {
switch (e.key) {
case " ":
this.calciteTreeItemSelect.emit({
modifyCurrentSelection: e.shiftKey,
modifyCurrentSelection: this.isSelectionMulti(),
forceToggle: false
});

Expand All @@ -288,7 +288,7 @@ export class CalciteTreeItem implements ConditionalSlotComponent {
this.selected = true;
} else {
this.calciteTreeItemSelect.emit({
modifyCurrentSelection: e.shiftKey,
modifyCurrentSelection: this.isSelectionMulti(),
forceToggle: false
});
}
Expand Down Expand Up @@ -429,4 +429,11 @@ export class CalciteTreeItem implements ConditionalSlotComponent {
return;
}
};

private isSelectionMulti(): boolean {
return (
this.selectionMode === TreeSelectionMode.Multi ||
this.selectionMode === TreeSelectionMode.MultiChildren
);
}
}
1 change: 0 additions & 1 deletion src/components/calcite-tree/calcite-tree.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ describe("calcite-tree", () => {
await item1.click();

expect(await getSelectedIds()).toEqual(["1"]);
await page.keyboard.down("Shift");

await item2.click();

Expand Down