Skip to content

Commit 90ef883

Browse files
committed
fix(material/tree): Apply aria-level to all nodes
Previously, only leaf nodes had aria-level applied. This is an incremental change since this is an unfamiliar codebase for me. The main benefit it will have on its own is that it will allow anyone doing custom dom manipulation to know what level the node is on. Otherwise by itself there is no change in how NVDA reads nodes with children. (It currently reads them as literally "grouping"; no information about the contents is provided). This change will be necessary for a later change I'm planning, wherein the role of parent nodes will be changed from "group" to "treeitem", in accordance with how roles are applied in WAI-ARIA reference examples such as https://www.w3.org/TR/wai-aria-practices/examples/treeview/treeview-1/treeview-1b.html
1 parent 61b423a commit 90ef883

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/cdk/tree/tree.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ export class CdkTree<T> implements AfterContentChecked, CollectionViewer, OnDest
291291
exportAs: 'cdkTreeNode',
292292
host: {
293293
'[attr.aria-expanded]': 'isExpanded',
294-
'[attr.aria-level]': 'role === "treeitem" ? level : null',
294+
'[attr.aria-level]': 'level',
295295
'[attr.role]': 'role',
296296
'class': 'cdk-tree-node',
297297
},

src/material/tree/node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const _MatTreeNodeMixinBase: HasTabIndexCtor & CanDisableCtor & typeof CdkTreeNo
4444
inputs: ['disabled', 'tabIndex'],
4545
host: {
4646
'[attr.aria-expanded]': 'isExpanded',
47-
'[attr.aria-level]': 'role === "treeitem" ? level : null',
47+
'[attr.aria-level]': 'level',
4848
'[attr.role]': 'role',
4949
'class': 'mat-tree-node'
5050
},

0 commit comments

Comments
 (0)