diff --git a/changelogs/upcoming/7513.md b/changelogs/upcoming/7513.md index 84fcb4496aaf..30a64d7248ab 100644 --- a/changelogs/upcoming/7513.md +++ b/changelogs/upcoming/7513.md @@ -1,3 +1,7 @@ +**Bug fixes** + +- Fixed an `EuiTreeView` bug where `aria-expanded` was being applied to items without expandable children + **CSS-in-JS conversions** - Converted `EuiTreeView` to Emotion. Updates as part of the conversion: diff --git a/src/components/tree_view/tree_view.tsx b/src/components/tree_view/tree_view.tsx index 9ab2a2fd425b..b54eaf8178aa 100644 --- a/src/components/tree_view/tree_view.tsx +++ b/src/components/tree_view/tree_view.tsx @@ -309,7 +309,9 @@ export class EuiTreeViewClass extends Component< {items.map((node, index) => { const buttonId = node.id; const wrappingId = this.treeIdGenerator(buttonId); - const isNodeExpanded = this.isNodeOpen(node); + const isNodeExpanded = node.children + ? this.isNodeOpen(node) + : undefined; // Determines the `aria-expanded` attribute let icon = node.icon; if (node.iconWhenExpanded && isNodeExpanded) {