-
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, tip-manager): respect user hidden attribute #10515
fix(combobox, stepper, table, tip-manager): respect user hidden attribute #10515
Conversation
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.
Solid start, @josercarcamo! Can you look at introducing a pattern for components that need to control visibility of their children? Namely to:
- define a property to use instead of
hidden
- add utilities to help determine visibility of these items (e.g., checks for
hidden
and the property defined in 1)
You've got most of this in place already. 🎉
Here are some notes:
- let's avoid
user
in the internal hidden prop name - we can omit adding stories since
hidden
is a global attribute and we don't test these - you can skip all tip-related components since these are deprecated and will be removed in v4.
@@ -217,6 +217,9 @@ export class StepperItem | |||
} | |||
|
|||
async componentWillLoad(): Promise<void> { | |||
if (this.el.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.
FIXME: Returning early will prevent the component from properly initializing.
@@ -253,7 +258,7 @@ export class StepperItem | |||
<div class={CSS.container}> | |||
{this.complete && ( | |||
<span aria-live="polite" class={CSS.visuallyHidden}> | |||
{this.messages.complete} | |||
{this.messages?.complete} |
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.
Adding an optional chain operator shouldn't be necessary. This is caused by skipping initialization logic in component lifecycle hooks.
@@ -386,6 +391,7 @@ export class StepperItem | |||
private handleItemClick = (event: MouseEvent): void => { | |||
if ( | |||
this.disabled || | |||
event.composedPath().some((el) => (el as HTMLElement).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.
Was this added for a particular use case? hidden
in most cases would not display the element and thus not be clickable. Applies to other hidden
-related logic in this PR.
This might affect test changes.
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.
Yes, this was added for the test case "should emit calciteStepperChange/calciteStepperItemChange on user interaction" where it directly queries for an element and clicks on it, even when it is disabled and, with this change, hidden.
expect(await step2Content.isVisible()).toBe(false); | ||
expect(await step3Content.isVisible()).toBe(false); | ||
it("navigates disabled and hidden items correctly with nextStep and prevStep methods", 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.
FIXME: avoid unnecessary/non-standard abbreviations.
@@ -119,6 +122,10 @@ export class TableRow implements InteractiveComponent, LocalizedComponent { | |||
// | |||
//-------------------------------------------------------------------------- | |||
|
|||
connectedCallback(): void { | |||
this.userHidden = this.el.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.
FIXME: This property is prone to getting out of sync since there are no configured watchers. If we introduce a new, internal prop for hiding components (if needed by their spec), this will be simplified.
} | ||
|
||
async componentWillLoad(): Promise<void> { | ||
await setUpMessages(this); | ||
this.setUpTips(); |
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.
FIXME: this needs to be restored, so they are called again whenever the component is moved or added to the DOM.
expect(await step2Content.isVisible()).toBe(false); | ||
expect(await step3Content.isVisible()).toBe(false); | ||
it("navigates disabled and hidden items correctly with nextStep and prevStep methods", 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.
FIXME: Since testing both hidden
and disabled
are related here, can you update the test by adding a hidden item and updating assertions instead of running another test? Applies to all tests in this and other E2E suites.
This would render the above abbreviation FIXME obsolete.
@@ -870,6 +884,50 @@ describe("calcite-stepper", () => { | |||
expect(itemChangeSpy).toHaveReceivedEventTimes(2); | |||
}); | |||
|
|||
it("should emit calciteStepperItemChange on user interaction when item is hidden", 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.
Can you merge this with the should emit calciteStepperItemChange on user interaction
test (i.e., tests would include both hidden and disabled items)?
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. |
827a0bc
to
d94d8db
Compare
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. |
Superseded by #10983 |
**Related Issue:** #8623 ## Summary Made items with the hide-item attribute added by the user stay hidden. This PR supersedes #10515 ## Wiki page https://github.com/Esri/calcite-design-system/wiki/hiddenItem-Property
Related Issue: #8623
Summary
Made items with the hidden attribute added by the user stay hidden.