components icon indicating copy to clipboard operation
components copied to clipboard

bug(cdk-tree): aria-expanded attribute should not appear in the leaf node

Open Yueyue07 opened this issue 3 years ago • 5 comments

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 image 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

Yueyue07 avatar Feb 16 '21 16:02 Yueyue07

@jelbourn I would like to submit a PR for this.

chaitanya-hdoc avatar Mar 02 '21 13:03 chaitanya-hdoc

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

nico151999 avatar Mar 08 '21 17:03 nico151999

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.

behofer avatar Mar 09 '21 07:03 behofer

This is still an issue. Aria-expanded should only exist on node with children. Hopefully this can get fixed soon. Thanks!

stephanie-cherba avatar Apr 16 '24 02:04 stephanie-cherba

Hello folks, Fix in progress, see cdk-tree-revamp branch. -Zach

zarend avatar Apr 22 '24 18:04 zarend