Skip to content
Merged
Show file tree
Hide file tree
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
55 changes: 55 additions & 0 deletions packages/main/cypress/specs/List.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import Option from "../../src/Option.js";
import CheckBox from "../../src/CheckBox.js";
import Bar from "../../src/Bar.js";
import Link from "../../src/Link.js";
import Panel from "../../src/Panel.js";
import Label from "../../src/Label.js";

function getGrowingWithScrollList(length: number, height: string = "100px") {
return (
Expand Down Expand Up @@ -205,6 +207,59 @@ describe("List Tests", () => {
.should("have.class", "ui5-hidden-text")
.should("contain.text", "This button will load additional products to the list. Click or press Enter to see more items.");
});

it("does not fire item-toggle for nested panel toggle events", () => {
cy.mount(
<List>
<ListItemCustom>
<Panel headerText="Panel A" style={{ width: "100%" }}>
<Label>Panel A content</Label>
</Panel>
</ListItemCustom>
</List>
);

cy.get("[ui5-list]").as("list");

cy.get("@list")
.then(list => {
list.get(0).addEventListener("ui5-item-toggle", cy.stub().as("itemToggle"));
});

cy.get("[ui5-panel]")
.shadow()
.find(".ui5-panel-header")
.realClick();

cy.get("[ui5-panel]")
.should("have.attr", "collapsed");

cy.get("@itemToggle")
.should("not.have.been.called");
});

it("does not crash when a bubbling ui5-toggle has null detail", () => {
cy.mount(
<List>
<ListItemCustom id="listItemWithNestedContent">
<div>Nested interactive content</div>
</ListItemCustom>
</List>
);

cy.window().then(win => {
const listItem = win.document.getElementById("listItemWithNestedContent");
const toggleEvent = new win.CustomEvent("ui5-toggle", {
detail: null,
bubbles: true,
composed: true,
});

listItem?.dispatchEvent(toggleEvent);
});

cy.get("[ui5-list]").should("exist");
});
});

describe("List - Growing with scroll", () => {
Expand Down
8 changes: 7 additions & 1 deletion packages/main/src/List.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1419,7 +1419,13 @@ class List extends UI5Element {
return;
}

this.fireDecoratorEvent("item-toggle", { item: e.detail.item });
const item = e.detail?.item;

if (!item) {
return;
}

this.fireDecoratorEvent("item-toggle", { item });
}

onForwardBefore(e: CustomEvent) {
Expand Down
Loading