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

fix(combobox, stepper, table, tip-manager): respect user hidden attribute #10515

Closed

Conversation

josercarcamo
Copy link
Contributor

Related Issue: #8623

Summary

Made items with the hidden attribute added by the user stay hidden.

@github-actions github-actions bot added the bug Bug reports for broken functionality. Issues should include a reproduction of the bug. label Oct 9, 2024
@josercarcamo josercarcamo marked this pull request as draft October 9, 2024 19:49
@josercarcamo josercarcamo added the pr ready for visual snapshots Adding this label will run visual snapshot testing. label Oct 10, 2024
@josercarcamo josercarcamo added pr ready for visual snapshots Adding this label will run visual snapshot testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels Oct 21, 2024
@josercarcamo josercarcamo marked this pull request as ready for review October 23, 2024 17:36
Copy link
Member

@jcfranco jcfranco left a 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:

  1. define a property to use instead of hidden
  2. 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) {
Copy link
Member

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}
Copy link
Member

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) ||
Copy link
Member

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.

Copy link
Contributor Author

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"]) {
Copy link
Member

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;
Copy link
Member

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();
Copy link
Member

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"]) {
Copy link
Member

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 () => {
Copy link
Member

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)?

Copy link
Contributor

github-actions bot commented Nov 1, 2024

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.

@github-actions github-actions bot added the Stale Issues or pull requests that have not had recent activity. label Nov 1, 2024
@github-actions github-actions bot removed the Stale Issues or pull requests that have not had recent activity. label Nov 16, 2024
@josercarcamo josercarcamo force-pushed the josercarcamo/8623-respect-user-hidden-attribute branch from 827a0bc to d94d8db Compare November 25, 2024 21:55
Copy link
Contributor

github-actions bot commented Dec 3, 2024

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.

@github-actions github-actions bot added the Stale Issues or pull requests that have not had recent activity. label Dec 3, 2024
@josercarcamo
Copy link
Contributor Author

Superseded by #10983

josercarcamo added a commit that referenced this pull request Jan 22, 2025
**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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug reports for broken functionality. Issues should include a reproduction of the bug. pr ready for visual snapshots Adding this label will run visual snapshot testing. Stale Issues or pull requests that have not had recent activity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants