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

[WIP] feat: add demo for tree-view-type-ahead #39

Closed
wants to merge 3 commits into from

Conversation

Shijir
Copy link
Contributor

@Shijir Shijir commented Mar 23, 2022

Signed-off-by: stsogoo stsogoo@vmware.com

PR Checklist

Please check if your PR fulfills the following requirements:

Enable Type-Ahead functionaly Tree-View by introducing clrTypeAhead directive.

clrTypeAhead directive works as a support/helper directive to enable a type-ahead focus functionality in Tree-View component. Its only goal is to extract the text content from its host element. This directive can extract and provide element's text content in two ways:

  1. Accessing .textContent from its native element. Example:
<clr-tree-node clrTypeAhead>Hello World<clr-tree-node>
  1. Via input binding (Recommend). Example:
<clr-tree-node [clrTypeAhead]='Hello World'>Hello World<clr-tree-node>

In this way, the user directly provides the text through input binding. This is better because the directive doesn't need to access the element to extract its text content.

In this current implementation, Type-Ahead functionality is optional in Tree-View as not all Tree-View components need this functionality. Thus, in order to enable this functionality, users need to import ClrTypeAheadModule together with ClrTreeViewModule.

Recursive Tree-View with Type-Ahead:

<clr-tree>
    <clr-tree-node
      [clrForTypeAhead]="node.name"
      *clrRecursiveFor="let node of multiRoot">
      {{node.name}}
    </clr-tree-node>
</clr-tree>

Declaritive Tree-View with Type-Ahead:

<clr-tree>
    <clr-tree-node clrForTypeAhead [clrExpanded]="true">
      California
      <clr-tree-node clrForTypeAhead>San Francisco</clr-tree-node>
      <clr-tree-node clrForTypeAhead>Los Angeles</clr-tree-node>
    </clr-tree-node>
    <clr-tree-node clrForTypeAhead [clrExpanded]="true">
      Washington
      <clr-tree-node clrForTypeAhead>Seattle</clr-tree-node>
    </clr-tree-node>
</clr-tree>
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • If applicable, have a visual design approval

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: VPAT-604: Tree Views lack Type-ahead functionality https://jira.eng.vmware.com/plugins/servlet/samlsso?redirectTo=%2Fbrowse%2FVPAT-604

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@Shijir Shijir changed the title feat: add demo for tree-view-type-ahead [WIP] feat: add demo for tree-view-type-ahead Mar 23, 2022
@vmwclabot
Copy link

@Shijir, you must sign our contributor license agreement before your changes are merged. Click here to sign the agreement. If you are a VMware employee, read this for further instruction.

@vmwclabot
Copy link

@Shijir, your company's legal contact has approved your signed contributor license agreement. It will also be reviewed by VMware, but the merge can proceed.

Signed-off-by: stsogoo <stsogoo@vmware.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 24, 2022

👋 @Shijir,

  • 🙏 The Clarity team thanks you for opening a pull request
  • 🎉 The build for this PR has succeeded
  • 🔍 The PR is now ready for review
  • 🍿 In the meantime, checkout out a preview of this PR
  • 🖐 You can always follow up here. If you're a VMware employee, you can also reach us on our internal #clarity-support Slack channel

Thank you,

🤖 Clarity Release Bot

@@ -188,6 +199,20 @@ export class ClrTreeNode<T> implements OnInit, OnDestroy {
this.subscriptions.push(
this._model.loading$.pipe(debounceTime(0)).subscribe(isLoading => (this.isModelLoading = isLoading))
);

this.subscriptions.push(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out the takeUntil/destroy pattern in this PR

@@ -99,6 +99,71 @@ export class TreeFocusManagerService<T> {
}
}

private findNodeStartsWith(searchString: string, model: TreeNodeModel<T>): TreeNodeModel<T> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the return type should be TreeNodeModel<T> | null

return null;
}

private findClosestNodeStartsWith(searchString: string, model: TreeNodeModel<T>): TreeNodeModel<T> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the return type should be TreeNodeModel<T> | null

return null;
}

// Look from its own descendents first
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are lots of chunks of logic in these private functions that might be easier to unit test in isolation as utilities or helpers

Signed-off-by: stsogoo <stsogoo@vmware.com>
Signed-off-by: stsogoo <stsogoo@vmware.com>
@Shijir
Copy link
Contributor Author

Shijir commented Apr 1, 2022

Closing this PR as a topic branch PR is created instead: #61

@Shijir Shijir closed this Apr 1, 2022
@github-actions
Copy link
Contributor

Hi there 👋, this is an automated message. To help Clarity keep track of discussions, we automatically lock closed PRs after 14 days. Please look for another open issue or open a new issue with updated details and reference this one as necessary.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 16, 2022
@vmwclabot
Copy link

@Shijir, VMware has rejected your signed contributor license agreement. The merge can not proceed until the agreement has been resigned. Click here to resign the agreement.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants