-
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
base: dev
Are you sure you want to change the base?
fix(combobox, stepper, table): respect user hidden attribute #10983
Conversation
@josercarcamo This is missing the utilities mentioned in item 2 from the previous review. Could you update your PR to include them? Since this supersedes the previous PR, can you close it? |
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.
Good progress, @josercarcamo! 😎 This needs a few more tweaks, and it'll be good to go!
@@ -97,10 +97,8 @@ | |||
} | |||
|
|||
@mixin base-component() { | |||
:host([hidden]) { |
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?
* 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for removing user
from the prop name! To align with hidden
, WDYT about hiddenItem
?
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -1642,9 +1689,8 @@ describe("keyboard navigation", () => { | |||
await page.keyboard.press("PageUp"); | |||
await page.waitForChanges(); | |||
expect(await getFocusedElementProp(page, "id")).toBe("head-1b"); | |||
await page.keyboard.down("ControlRight"); | |||
page.keyboard.press("ControlRight"); |
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.
This should use await
and changing it to press
will cause it to no longer go into the expected End
+ ControlRight
path here (i.e., ControlRight
is pressed and released before End
is pressed).
This PR has been automatically marked as stale because it has not had recent activity. Please close your PR if it is no longer relevant. Thank you for your contributions. |
@jcfranco please review again. |
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.
Great stuff, @josercarcamo! One more pass and this should be good to go!
BTW, these changes caused some combobox
and input-time-zone
tests to fail, so they'll need to be updated.
@@ -863,6 +863,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 comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use the html
formatting helper, so prettier formats embedded HTML? Applies to other test page markup.
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"); |
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.
Can you update this test to step through the hidden item? It currently skips it: 1 ➡️ 3 (skips 2) ⬅️ 1 (skips 2). It should still be ignored, but the test should at least step through it.
</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 comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use it.each
for this instead.
@@ -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" hidden> |
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.
For consistency, can you update all steps to be integers?
@@ -274,6 +281,8 @@ export class StepperItem extends LitElement implements InteractiveComponent, Loa | |||
private handleItemClick(event: MouseEvent): void { | |||
if ( | |||
this.disabled || | |||
this.hiddenItem || |
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.
This can use isHidden
, right?
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.
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.
Can you try passing the element instead of the instance? You'll get that error if you pass the latter.
@@ -26,3 +29,7 @@ export function warnIfMissingRequiredProp<C extends LitElement>( | |||
logger.warn(`[${component.el.localName}] "${newProp.toString()}" or "${deprecatedProp.toString()}" is required.`); | |||
} | |||
} | |||
|
|||
export function isHidden<C extends ComboboxChildElement | StepperItem["el"] | TableRow["el"]>(component: C): boolean { | |||
return component?.hidden || component?.hiddenItem; |
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.
Can component
be undefined
here?
const items = await page.findAll("calcite-table-row"); | ||
for (let i = 0; i < items.length; i++) { | ||
const style = await items[i].getComputedStyle(); | ||
expect(style["display"]).toBe(i === 2 || i === 3 ? "none" : "contents"); |
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.
This test might go away, but I think you can use E2EElement.isVisible
for these assertions.
@@ -34,6 +34,41 @@ describe("calcite-table", () => { | |||
</calcite-table>`, | |||
{ display: "flex" }, | |||
); | |||
|
|||
it("renders only non-hidden rows", async () => { |
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.
I think we can drop this test since it's testing native browser behavior.
@@ -26,3 +29,7 @@ export function warnIfMissingRequiredProp<C extends LitElement>( | |||
logger.warn(`[${component.el.localName}] "${newProp.toString()}" or "${deprecatedProp.toString()}" is required.`); | |||
} | |||
} | |||
|
|||
export function isHidden<C extends ComboboxChildElement | StepperItem["el"] | TableRow["el"]>(component: C): boolean { |
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.
For consistency, can we rename the input argument to el
?
@jcfranco one more review please. |
Related Issue: #8623
Summary
Made items with the hide-item attribute added by the user stay hidden.
This PR supersedes #10515