Skip to content

Commit

Permalink
docs(cdk/tree): fix several live example issues (#29875)
Browse files Browse the repository at this point in the history
Fixes the following issues with the tree live examples:
* Both the tree node and the toggle were marked as toggles which meant that clicking anywhere would close the tree.
* The toggles weren't centered relative to the text.
* A couple of examples had the same name and one had weird punctuation.

Fixes #29830.

(cherry picked from commit 52cad9c)
  • Loading branch information
crisbeto committed Oct 14, 2024
1 parent b5ff571 commit 82d9fe2
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@
.example-tree-node .example-tree-node {
padding-left: 40px;
}

.example-toggle {
vertical-align: middle;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
</cdk-nested-tree-node>
<!-- This is the tree node template for expandable nodes -->
<cdk-nested-tree-node #treeNode="cdkNestedTreeNode"
cdkTreeNodeToggle
*cdkTreeNodeDef="let node; when: hasChild"
[cdkTreeNodeTypeaheadLabel]="node.name"
isExpandable
class="example-tree-node">
<button mat-icon-button [attr.aria-label]="'Toggle ' + node.name" cdkTreeNodeToggle>
*cdkTreeNodeDef="let node; when: hasChild"
[cdkTreeNodeTypeaheadLabel]="node.name"
isExpandable
class="example-tree-node">
<button
mat-icon-button
class="example-toggle"
[attr.aria-label]="'Toggle ' + node.name"
cdkTreeNodeToggle>
<mat-icon class="mat-icon-rtl-mirror">
{{tree.isExpanded(node) ? 'expand_more' : 'chevron_right'}}
</mat-icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function flattenNodes(nodes: NestedFoodNode[]): NestedFoodNode[] {
}

/**
* @title Tree with nested nodes, using childAccessor
* @title Tree with nested nodes using childAccessor
*/
@Component({
selector: 'cdk-tree-nested-children-accessor-example',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@
.example-tree-node .example-tree-node {
padding-left: 40px;
}

.example-toggle {
vertical-align: middle;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@
{{node.name}}
</cdk-nested-tree-node>
<!-- This is the tree node template for expandable nodes -->
<cdk-nested-tree-node #treeNode="cdkNestedTreeNode"
cdkTreeNodeToggle
[cdkTreeNodeTypeaheadLabel]="node.name"
*cdkTreeNodeDef="let node; when: hasChild"
isExpandable
class="example-tree-node">
<button mat-icon-button [attr.aria-label]="'Toggle ' + node.name" cdkTreeNodeToggle>
<cdk-nested-tree-node
#treeNode="cdkNestedTreeNode"
[cdkTreeNodeTypeaheadLabel]="node.name"
*cdkTreeNodeDef="let node; when: hasChild"
isExpandable
class="example-tree-node">
<button
mat-icon-button
class="example-toggle"
[attr.aria-label]="'Toggle ' + node.name"
cdkTreeNodeToggle>
<mat-icon class="mat-icon-rtl-mirror">
{{tree.isExpanded(node) ? 'expand_more' : 'chevron_right'}}
</mat-icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {MatIconModule} from '@angular/material/icon';
import {FLAT_DATA, FlatFoodNode} from '../tree-data';

/**
* @title Tree with nested nodes
* @title Tree with nested nodes and level accessor
*/
@Component({
selector: 'cdk-tree-nested-level-accessor-example',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@
.example-tree-node .example-tree-node {
padding-left: 40px;
}

.example-toggle {
vertical-align: middle;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
</cdk-nested-tree-node>
<!-- This is the tree node template for expandable nodes -->
<cdk-nested-tree-node #treeNode="cdkNestedTreeNode"
cdkTreeNodeToggle
[cdkTreeNodeTypeaheadLabel]="node.name"
*cdkTreeNodeDef="let node; when: hasChild"
isExpandable
class="example-tree-node">
<button mat-icon-button [attr.aria-label]="'Toggle ' + node.name" cdkTreeNodeToggle>
[cdkTreeNodeTypeaheadLabel]="node.name"
*cdkTreeNodeDef="let node; when: hasChild"
isExpandable
class="example-tree-node">
<button
mat-icon-button
class="example-toggle"
[attr.aria-label]="'Toggle ' + node.name"
cdkTreeNodeToggle>
<mat-icon class="mat-icon-rtl-mirror">
{{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}}
</mat-icon>
Expand Down

0 comments on commit 82d9fe2

Please sign in to comment.