-
Notifications
You must be signed in to change notification settings - Fork 77
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
fix(combobox, stepper, table): respect user hidden attribute #10983
Changes from 2 commits
6dfa7c9
cddcabd
ff38449
e843d98
e425670
1c3680c
4772e23
46686b4
dfb66ae
759791a
eee513d
3e38b65
284d75c
09af985
c88ca71
a90211f
7d1f446
f8a9016
37cabf8
3e146b9
1d4a2d3
a46227d
da25db2
ca3fedc
a3ea10a
7da4daa
4f6d67a
e07beac
8c8c883
d867b85
26f24a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,6 +131,12 @@ export class ComboboxItem extends LitElement implements InteractiveComponent { | |
*/ | ||
@property() value: any; | ||
|
||
/** | ||
* Specifies whether the user set the hidden attribute in the HTML | ||
* | ||
*/ | ||
@property() hideItem = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for removing |
||
|
||
// #endregion | ||
|
||
// #region Events | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -783,6 +783,56 @@ describe("calcite-combobox", () => { | |
} | ||
}); | ||
|
||
it("should show correct number of items when child hidden", async () => { | ||
const page = await newE2EPage(); | ||
await page.setContent(` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you use the |
||
<calcite-combobox label="custom values" allow-custom-values placeholder="placeholder" max-items="6"> | ||
<calcite-combobox-item value="Trees" text-label="Trees" selected> | ||
<calcite-combobox-item value="Pine" text-label="Pine"> | ||
<calcite-combobox-item value="Pine Nested" text-label="Pine Nested"></calcite-combobox-item> | ||
</calcite-combobox-item> | ||
<calcite-combobox-item value="Sequoia" hide-item text-label="Sequoia"></calcite-combobox-item> | ||
<calcite-combobox-item value="Douglas Fir" text-label="Douglas Fir"></calcite-combobox-item> | ||
</calcite-combobox-item> | ||
<calcite-combobox-item value="Rocks" text-label="Rocks"></calcite-combobox-item> | ||
</calcite-combobox> | ||
`); | ||
await page.waitForChanges(); | ||
|
||
const element = await page.find("calcite-combobox"); | ||
await element.click(); | ||
await page.waitForChanges(); | ||
const items = await page.findAll("calcite-combobox-item, calcite-combobox-item-group"); | ||
for (let i = 0; i < items.length; i++) { | ||
expect(await items[i].isIntersectingViewport()).toBe(i !== 3); | ||
} | ||
}); | ||
|
||
it("should show correct number of items when parent hidden", async () => { | ||
const page = await newE2EPage(); | ||
await page.setContent(` | ||
<calcite-combobox label="custom values" allow-custom-values placeholder="placeholder" max-items="6"> | ||
<calcite-combobox-item value="Trees" text-label="Trees" hide-item> | ||
<calcite-combobox-item value="Pine" text-label="Pine"> | ||
<calcite-combobox-item value="Pine Nested" text-label="Pine Nested"></calcite-combobox-item> | ||
</calcite-combobox-item> | ||
<calcite-combobox-item value="Sequoia" disabled text-label="Sequoia"></calcite-combobox-item> | ||
<calcite-combobox-item value="Douglas Fir" text-label="Douglas Fir"></calcite-combobox-item> | ||
</calcite-combobox-item> | ||
<calcite-combobox-item value="Rocks" text-label="Rocks"></calcite-combobox-item> | ||
</calcite-combobox> | ||
`); | ||
await page.waitForChanges(); | ||
|
||
const element = await page.find("calcite-combobox"); | ||
await element.click(); | ||
await page.waitForChanges(); | ||
const items = await page.findAll("calcite-combobox-item, calcite-combobox-item-group"); | ||
for (let i = 0; i < items.length; i++) { | ||
expect(await items[i].isIntersectingViewport()).toBe(i === 5); | ||
} | ||
}); | ||
|
||
it("should show correct max items after selection", async () => { | ||
const page = await newE2EPage(); | ||
const maxItems = 6; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -249,7 +249,7 @@ describe("calcite-stepper", () => { | |
expect(await step4Content.isVisible()).toBe(false); | ||
}); | ||
|
||
it("navigates disabled items correctly with nextStep and prevStep methods", async () => { | ||
it("navigates disabled and hidden items correctly with nextStep and prevStep methods", async () => { | ||
const page = await newE2EPage(); | ||
await page.setContent( | ||
html`<calcite-stepper> | ||
|
@@ -262,37 +262,48 @@ describe("calcite-stepper", () => { | |
<calcite-stepper-item heading="Step 3" id="step-3"> | ||
<div>Step 3 content</div> | ||
</calcite-stepper-item> | ||
<calcite-stepper-item heading="Step 4" id="step-4" hide-item> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
<div>Step 4 content</div> | ||
</calcite-stepper-item> | ||
</calcite-stepper>`, | ||
); | ||
const element = await page.find("calcite-stepper"); | ||
const step1 = await page.find("#step-1"); | ||
const step2 = await page.find("#step-2"); | ||
const step3 = await page.find("#step-3"); | ||
const step4 = await page.find("#step-4"); | ||
const step1Content = await page.find("#step-1 >>> .stepper-item-content"); | ||
const step2Content = await page.find("#step-2 >>> .stepper-item-content"); | ||
const step3Content = await page.find("#step-3 >>> .stepper-item-content"); | ||
const step4Content = await page.find("#step-4 >>> .stepper-item-content"); | ||
expect(step1).toHaveAttribute("selected"); | ||
expect(step2).not.toHaveAttribute("selected"); | ||
expect(step3).not.toHaveAttribute("selected"); | ||
expect(step4).not.toHaveAttribute("selected"); | ||
expect(await step1Content.isVisible()).toBe(true); | ||
expect(await step2Content.isVisible()).toBe(false); | ||
expect(await step3Content.isVisible()).toBe(false); | ||
expect(await step4Content.isVisible()).toBe(false); | ||
await element.callMethod("nextStep"); | ||
await page.waitForChanges(); | ||
expect(step1).not.toHaveAttribute("selected"); | ||
expect(step2).not.toHaveAttribute("selected"); | ||
expect(step3).toHaveAttribute("selected"); | ||
expect(step4).not.toHaveAttribute("selected"); | ||
expect(await step1Content.isVisible()).toBe(false); | ||
expect(await step2Content.isVisible()).toBe(false); | ||
expect(await step3Content.isVisible()).toBe(true); | ||
expect(await step4Content.isVisible()).toBe(false); | ||
await element.callMethod("prevStep"); | ||
await page.waitForChanges(); | ||
expect(step1).toHaveAttribute("selected"); | ||
expect(step2).not.toHaveAttribute("selected"); | ||
expect(step3).not.toHaveAttribute("selected"); | ||
expect(step4).not.toHaveAttribute("selected"); | ||
jcfranco marked this conversation as resolved.
Show resolved
Hide resolved
|
||
expect(await step1Content.isVisible()).toBe(true); | ||
expect(await step2Content.isVisible()).toBe(false); | ||
expect(await step3Content.isVisible()).toBe(false); | ||
expect(await step4Content.isVisible()).toBe(false); | ||
}); | ||
|
||
it("navigates correctly with startStep and endStep methods", async () => { | ||
|
@@ -344,7 +355,7 @@ describe("calcite-stepper", () => { | |
expect(await step4Content.isVisible()).toBe(true); | ||
}); | ||
|
||
it("navigates disabled items correctly with startStep and endStep methods", async () => { | ||
it("navigates disabled and hidden items correctly with startStep and endStep methods", async () => { | ||
const page = await newE2EPage(); | ||
await page.setContent( | ||
html`<calcite-stepper> | ||
|
@@ -360,37 +371,46 @@ describe("calcite-stepper", () => { | |
<calcite-stepper-item heading="Step 4" id="step-4" disabled> | ||
<div>Step 4 content</div> | ||
</calcite-stepper-item> | ||
<calcite-stepper-item heading="Step 5" id="step-5" hide-item> | ||
<div>Step 5 content</div> | ||
</calcite-stepper-item> | ||
</calcite-stepper>`, | ||
); | ||
const element = await page.find("calcite-stepper"); | ||
const step1 = await page.find("#step-1"); | ||
const step2 = await page.find("#step-2"); | ||
const step3 = await page.find("#step-3"); | ||
const step4 = await page.find("#step-4"); | ||
const step5 = await page.find("#step-5"); | ||
const step1Content = await page.find("#step-1 >>> .stepper-item-content"); | ||
const step2Content = await page.find("#step-2 >>> .stepper-item-content"); | ||
const step3Content = await page.find("#step-3 >>> .stepper-item-content"); | ||
const step4Content = await page.find("#step-4 >>> .stepper-item-content"); | ||
const step5Content = await page.find("#step-5 >>> .stepper-item-content"); | ||
await element.callMethod("endStep"); | ||
await page.waitForChanges(); | ||
expect(step1).not.toHaveAttribute("selected"); | ||
expect(step2).not.toHaveAttribute("selected"); | ||
expect(step3).toHaveAttribute("selected"); | ||
expect(step4).not.toHaveAttribute("selected"); | ||
expect(step5).not.toHaveAttribute("selected"); | ||
expect(await step1Content.isVisible()).toBe(false); | ||
expect(await step2Content.isVisible()).toBe(false); | ||
expect(await step3Content.isVisible()).toBe(true); | ||
expect(await step4Content.isVisible()).toBe(false); | ||
expect(await step5Content.isVisible()).toBe(false); | ||
await element.callMethod("startStep"); | ||
await page.waitForChanges(); | ||
expect(step1).not.toHaveAttribute("selected"); | ||
expect(step2).toHaveAttribute("selected"); | ||
expect(step3).not.toHaveAttribute("selected"); | ||
expect(step4).not.toHaveAttribute("selected"); | ||
expect(step5).not.toHaveAttribute("selected"); | ||
expect(await step1Content.isVisible()).toBe(false); | ||
expect(await step2Content.isVisible()).toBe(true); | ||
expect(await step3Content.isVisible()).toBe(false); | ||
expect(await step4Content.isVisible()).toBe(false); | ||
expect(await step5Content.isVisible()).toBe(false); | ||
}); | ||
|
||
it("navigates to requested step with goToStep method", async () => { | ||
|
@@ -560,6 +580,10 @@ describe("calcite-stepper", () => { | |
expect(changeSpy).toHaveReceivedEventTimes(expectedEvents); | ||
expect(await getSelectedItemId()).toBe("step-4"); | ||
|
||
await page.$eval("#step-5", itemClicker); | ||
expect(itemChangeSpy).toHaveReceivedEventTimes(expectedEvents); | ||
expect(changeSpy).toHaveReceivedEventTimes(expectedEvents); | ||
|
||
await element.callMethod("prevStep"); | ||
await page.waitForChanges(); | ||
expect(itemChangeSpy).toHaveReceivedEventTimes(expectedEvents); | ||
|
@@ -592,6 +616,9 @@ describe("calcite-stepper", () => { | |
<calcite-stepper-item heading="Step 4" id="step-4"> | ||
<div>Step 4 content</div> | ||
</calcite-stepper-item> | ||
<calcite-stepper-item heading="Step 5" id="step-5" hide-item> | ||
<div>Step 5 content</div> | ||
</calcite-stepper-item> | ||
</calcite-stepper>`, | ||
); | ||
|
||
|
@@ -606,6 +633,7 @@ describe("calcite-stepper", () => { | |
<calcite-stepper-item heading="Step 2" id="step-2"></calcite-stepper-item> | ||
<calcite-stepper-item heading="Step 3" id="step-3" disabled></calcite-stepper-item> | ||
<calcite-stepper-item heading="Step 4" id="step-4"></calcite-stepper-item> | ||
<calcite-stepper-item heading="Step 5" id="step-5" hide-item></calcite-stepper-item> | ||
</calcite-stepper>`, | ||
); | ||
|
||
|
@@ -634,6 +662,9 @@ describe("calcite-stepper", () => { | |
<calcite-stepper-item heading="Step 4" id="step-4"> | ||
<div>Step 4 content</div> | ||
</calcite-stepper-item> | ||
<calcite-stepper-item heading="Step 5" id="step-5" hide-item> | ||
<div>Step 5 content</div> | ||
</calcite-stepper-item> | ||
</calcite-stepper>`, | ||
); | ||
|
||
|
@@ -648,6 +679,7 @@ describe("calcite-stepper", () => { | |
<calcite-stepper-item heading="Step 2" id="step-2"></calcite-stepper-item> | ||
<calcite-stepper-item heading="Step 3" id="step-3" disabled></calcite-stepper-item> | ||
<calcite-stepper-item heading="Step 4" id="step-4"></calcite-stepper-item> | ||
<calcite-stepper-item heading="Step 5" id="step-5" hide-item></calcite-stepper-item> | ||
</calcite-stepper>`, | ||
); | ||
|
||
|
@@ -739,22 +771,24 @@ describe("calcite-stepper", () => { | |
expect(await stepperItem3.getProperty("selected")).not.toBe(true); | ||
}); | ||
|
||
it("should select the next enabled stepper-item if first stepper-item is disabled", async () => { | ||
const page = await newE2EPage(); | ||
await page.setContent( | ||
html`<calcite-stepper> | ||
<calcite-stepper-item heading="Step 1" id="step-1" disabled> | ||
<div>Step 1 content</div> | ||
</calcite-stepper-item> | ||
<calcite-stepper-item heading="Step 2" id="step-2"> | ||
<div>Step 2 content</div> | ||
</calcite-stepper-item> | ||
</calcite-stepper>`, | ||
); | ||
it("should select the next enabled stepper-item if first stepper-item is disabled or hidden", async () => { | ||
for (const n of ["disabled", "hidden"]) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's use |
||
const page = await newE2EPage(); | ||
await page.setContent( | ||
html`<calcite-stepper> | ||
<calcite-stepper-item heading="Step 1" id="step-1" ${n}> | ||
<div>Step 1 content</div> | ||
</calcite-stepper-item> | ||
<calcite-stepper-item heading="Step 2" id="step-2"> | ||
<div>Step 2 content</div> | ||
</calcite-stepper-item> | ||
</calcite-stepper>`, | ||
); | ||
|
||
const [stepperItem1, stepperItem2] = await page.findAll("calcite-stepper-item"); | ||
expect(await stepperItem1.getProperty("selected")).toBe(false); | ||
expect(await stepperItem2.getProperty("selected")).toBe(true); | ||
const [stepperItem1, stepperItem2] = await page.findAll("calcite-stepper-item"); | ||
expect(await stepperItem1.getProperty("selected")).toBe(false); | ||
expect(await stepperItem2.getProperty("selected")).toBe(true); | ||
} | ||
}); | ||
|
||
describe("horizontal-single layout", () => { | ||
|
@@ -843,6 +877,9 @@ describe("calcite-stepper", () => { | |
<calcite-stepper-item heading="Step 2" id="step-2" disabled> | ||
<div>Step 2 content</div> | ||
</calcite-stepper-item> | ||
<calcite-stepper-item heading="Step 2.1" id="step-2.1" hide-item> | ||
<div>Step 2.1 content</div> | ||
</calcite-stepper-item> | ||
<calcite-stepper-item heading="Step 3" id="step-2"> | ||
<div>Step 3 content</div> | ||
</calcite-stepper-item> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the internal
hide-item
attribute is only applicable to certain components, can you create a separate mixin and include in applicable children?