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

feat(list-item, list): add expanded property and deprecate open property #11003

Merged
merged 17 commits into from
Mar 5, 2025
Merged
Changes from 1 commit
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
Next Next commit
feat(list-item): deprecate open/close props in favor of expanded/coll…
…apsed
  • Loading branch information
Elijbet committed Dec 6, 2024
commit 9f313a7a480ae7057c2455176901a4f6edee6393
Original file line number Diff line number Diff line change
@@ -45,6 +45,10 @@ describe("calcite-list-item", () => {
propertyName: "open",
defaultValue: false,
},
{
propertyName: "expanded",
defaultValue: false,
},
{
propertyName: "dragHandle",
defaultValue: false,
@@ -362,7 +366,7 @@ describe("calcite-list-item", () => {

expect(await listItem.getProperty("open")).toBe(false);

const openButton = await page.find(`calcite-list-item >>> .${CSS.openContainer}`);
const openButton = await page.find(`calcite-list-item >>> .${CSS.expandedContainer}`);

await openButton.click();
expect(await listItem.getProperty("open")).toBe(true);
@@ -373,6 +377,29 @@ describe("calcite-list-item", () => {
expect(calciteListItemToggle).toHaveReceivedEventTimes(2);
});

it("should fire calciteListItemToggle event when expanded and collapsed", async () => {
const page = await newE2EPage({
html: html`<calcite-list-item display-mode="nested"
><calcite-list><calcite-list-item></calcite-list-item></calcite-list
></calcite-list-item>`,
});

const listItem = await page.find("calcite-list-item");
const calciteListItemToggle = await page.spyOnEvent("calciteListItemToggle", "window");

expect(await listItem.getProperty("expanded")).toBe(false);

const openButton = await page.find(`calcite-list-item >>> .${CSS.expandedContainer}`);

await openButton.click();
expect(await listItem.getProperty("expanded")).toBe(true);
expect(calciteListItemToggle).toHaveReceivedEventTimes(1);

await openButton.click();
expect(await listItem.getProperty("expanded")).toBe(false);
expect(calciteListItemToggle).toHaveReceivedEventTimes(2);
});

it("should not fire calciteListItemToggle event without nested items", async () => {
const page = await newE2EPage({
html: html`<calcite-list-item display-mode="nested"></calcite-list-item>`,
@@ -383,7 +410,7 @@ describe("calcite-list-item", () => {

expect(await listItem.getProperty("open")).toBe(false);

const openButton = await page.find(`calcite-list-item >>> .${CSS.openContainer}`);
const openButton = await page.find(`calcite-list-item >>> .${CSS.expandedContainer}`);

expect(openButton.getAttribute("title")).toBe(null);

@@ -403,7 +430,7 @@ describe("calcite-list-item", () => {
></calcite-list-item>`,
});

const openButton = await page.find(`calcite-list-item >>> .${CSS.openContainer}`);
const openButton = await page.find(`calcite-list-item >>> .${CSS.expandedContainer}`);

expect(openButton).toBe(null);
});
Loading
Oops, something went wrong.