components
components copied to clipboard
bug(cdk-tree): aria-expanded attribute should not appear in the leaf node
Reproduction
Example to reproduce issue https://material.angular.io/cdk/tree/examples
Steps to reproduce:
Inspect the leaf node of cdk-tree from dev tools
Based on W3.org aria practices for tree view, it mentions that: "Each element with role treeitem that serves as a parent node has aria-expanded set to false when the node is in a closed state and set to true when the node is in an open state. End nodes do not have the aria-expanded attribute because, if they were to have it, they would be incorrectly described to assistive technologies as parent nodes."
Expected Behavior
There should be no aria-expanded attribute appearing on the leaf node
Actual Behavior
aria-expanded is setting as false on the leaf node
Environment
- CDK/Material: newest version
@jelbourn I would like to submit a PR for this.
I was reported by a screenreader user that it is quite confusing to face the expanded attribute being set on leaf elements. For accessibility reasons I would also like to see the behavior described by W3.org as mentioned by @Yueyue07
As a screenreader user, I can exactly see the behaviour described by @Yueyue07 consistently with different screenreaders. So, screenreaders are relying on aria-expanded being correctly set to describe tree nodes and their current states. From an accessibility perspective, A fix would be highly appreciated! Thanks.
This is still an issue. Aria-expanded should only exist on node with children. Hopefully this can get fixed soon. Thanks!
Hello folks, Fix in progress, see cdk-tree-revamp branch. -Zach