Skip to content

Commit fe4df3f

Browse files
walvekarnikhilandrewseguin
authored andcommitted
docs(tree): A11Y improvement for Nested Tree example. (#22583)
* docs(material/tree): A11Y improvement for Nested Tree example. Fixes #22517 * docs(material/tree): A11Y improvement for Nested Tree example. Fixes #22517 * docs(material/tree): Fixing nested tree styles. Use padding-left instead of padding-inline-start. (cherry picked from commit 46c2d26)
1 parent a3c5fab commit fe4df3f

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

src/components-examples/material/tree/tree-nested-overview/tree-nested-overview-example.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,19 @@
88
margin-bottom: 0;
99
list-style-type: none;
1010
}
11+
12+
/*
13+
* This padding sets alignment of the nested nodes.
14+
*/
15+
.example-tree .mat-nested-tree-node div[role=group] {
16+
padding-left: 40px;
17+
}
18+
19+
/*
20+
* Padding for leaf nodes.
21+
* Leaf nodes need to have padding so as to align with other non-leaf nodes
22+
* under the same parent.
23+
*/
24+
.example-tree div[role=group] > .mat-tree-node {
25+
padding-left: 40px;
26+
}
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
<mat-tree [dataSource]="dataSource" [treeControl]="treeControl" class="example-tree">
22
<!-- This is the tree node template for leaf nodes -->
3+
<!-- There is inline padding applied to this node using styles.
4+
This padding value depends on the mat-icon-button width. -->
35
<mat-tree-node *matTreeNodeDef="let node" matTreeNodeToggle>
4-
<li class="mat-tree-node">
5-
<!-- use a disabled button to provide padding for tree leaf -->
6-
<button mat-icon-button disabled></button>
76
{{node.name}}
8-
</li>
97
</mat-tree-node>
108
<!-- This is the tree node template for expandable nodes -->
119
<mat-nested-tree-node *matTreeNodeDef="let node; when: hasChild">
12-
<li>
1310
<div class="mat-tree-node">
1411
<button mat-icon-button matTreeNodeToggle
1512
[attr.aria-label]="'Toggle ' + node.name">
@@ -19,9 +16,11 @@
1916
</button>
2017
{{node.name}}
2118
</div>
22-
<ul [class.example-tree-invisible]="!treeControl.isExpanded(node)">
19+
<!-- There is inline padding applied to this div using styles.
20+
This padding value depends on the mat-icon-button width. -->
21+
<div [class.example-tree-invisible]="!treeControl.isExpanded(node)"
22+
role="group">
2323
<ng-container matTreeNodeOutlet></ng-container>
24-
</ul>
25-
</li>
24+
</div>
2625
</mat-nested-tree-node>
2726
</mat-tree>

0 commit comments

Comments
 (0)