-
Notifications
You must be signed in to change notification settings - Fork 6.8k
doc(tree):simplify tree example #14718
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
Conversation
src/material-examples/tree-flat-overview/tree-flat-overview-example.html
Outdated
Show resolved
Hide resolved
@@ -1,16 +1,16 @@ | |||
<mat-tree [dataSource]="dataSource" [treeControl]="treeControl"> | |||
<mat-tree-node *matTreeNodeDef="let node" matTreeNodeToggle matTreeNodePadding> | |||
<button mat-icon-button disabled></button> |
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 disabled hidden button is not intuitive or explained. We use it to offset extra padding but the user may not understand why this is here. Perhaps leave a comment saying that this is necessary because it helps offset leaf nodes, or provide an additional example-leaf-offset-padding class that explicitly provides this padding.
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.
added comment for now. We should provide a better template later.
@@ -1,16 +1,16 @@ | |||
<mat-tree [dataSource]="dataSource" [treeControl]="treeControl"> | |||
<mat-tree-node *matTreeNodeDef="let node" matTreeNodeToggle matTreeNodePadding> |
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 each tree-node should have some comment above that describes how they are distinguished. For example,
<!-- This is the tree node template for leaf nodes -->
<!-- This is the tree node template for expandable nodes -->
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.
done
src/material-examples/tree-flat-overview/tree-flat-overview-example.ts
Outdated
Show resolved
Hide resolved
src/material-examples/tree-nested-overview/tree-nested-overview-example.ts
Outdated
Show resolved
Hide resolved
@@ -2,20 +2,20 @@ | |||
<mat-tree-node *matTreeNodeDef="let node" matTreeNodeToggle> | |||
<li class="mat-tree-node"> | |||
<button mat-icon-button disabled></button> | |||
{{node.filename}}: {{node.type}} | |||
{{node.name}} | |||
</li> | |||
</mat-tree-node> | |||
|
|||
<mat-nested-tree-node *matTreeNodeDef="let node; when: hasNestedChild"> | |||
<li> |
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.
It's not clear to me (or the user) why this example uses <ul
> and </li>
tags.
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.
you are right. We should provide a better template in the following PR.
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.
Updated based Andrew's comment. Please review again.
8764de4
to
0ad5e60
Compare
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.
Remove MatTreeDatasource from CDK tree demo.
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.
LGTM - good first step in simplifying the tree
} | ||
|
||
hasNestedChild = (_: number, nodeData: FileNode) => !nodeData.type; | ||
treeControl: NestedTreeControl<FoodNode> = new NestedTreeControl<FoodNode>(node => node.children); |
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 remove the first type declaration
}) | ||
export class TreeNestedOverviewExample { | ||
nestedTreeControl: NestedTreeControl<FileNode>; | ||
nestedDataSource: MatTreeNestedDataSource<FileNode>; | ||
treeControl: NestedTreeControl<FoodNode> = new NestedTreeControl<FoodNode>(node => node.children); |
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.
The immediate typing can be removed since Typescript will infer from what you are creating
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Remove unnecessary code to better demonstrate how to use tree.