diff --git a/src/components/calcite-tree-item/calcite-tree-item.tsx b/src/components/calcite-tree-item/calcite-tree-item.tsx
index f26f1470c5d..6e110a11bf4 100644
--- a/src/components/calcite-tree-item/calcite-tree-item.tsx
+++ b/src/components/calcite-tree-item/calcite-tree-item.tsx
@@ -191,7 +191,7 @@ export class CalciteTreeItem {
}
this.expanded = !this.expanded;
this.calciteTreeItemSelect.emit({
- modifyCurrentSelection: (e as any).shiftKey,
+ modifyCurrentSelection: (e as any).shiftKey || this.inputEnabled,
forceToggle: false
});
}
diff --git a/src/components/calcite-tree/calcite-tree.e2e.ts b/src/components/calcite-tree/calcite-tree.e2e.ts
index a4356350b1f..70014f51d09 100644
--- a/src/components/calcite-tree/calcite-tree.e2e.ts
+++ b/src/components/calcite-tree/calcite-tree.e2e.ts
@@ -187,6 +187,47 @@ describe("calcite-tree", () => {
expect(selectEventSpy).toHaveReceivedEventTimes(3);
});
+ describe("has selected items in the selection event payload", () =>
+ it("contains current selection when selection=multi + input-enabled", async () => {
+ const page = await newE2EPage({
+ html: html`
+ 1
+ 2
+ `
+ });
+
+ const [item1, item2] = await page.findAll("calcite-tree-item");
+
+ type TestWindow = {
+ selectedIds: string[];
+ } & Window &
+ typeof globalThis;
+
+ await page.evaluateHandle(() =>
+ document.addEventListener("calciteTreeSelect", ({ detail }: CustomEvent) => {
+ (window as TestWindow).selectedIds = detail.selected.map((item) => item.id);
+ })
+ );
+
+ const getSelectedIds = async (): Promise => page.evaluate(() => (window as TestWindow).selectedIds);
+
+ await item1.click();
+
+ expect(await getSelectedIds()).toEqual(["1"]);
+
+ await item2.click();
+
+ expect(await getSelectedIds()).toEqual(["1", "2"]);
+
+ await item2.click();
+
+ expect(await getSelectedIds()).toEqual(["1"]);
+
+ await item1.click();
+
+ expect(await getSelectedIds()).toEqual([]);
+ }));
+
it("emits once when the tree item checkbox label is clicked", async () => {
const page = await newE2EPage({
html: html`