Skip to content

Commit

Permalink
[PR feedback] aria-expanded
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen committed Feb 7, 2024
1 parent 1845fbf commit 6b0cc92
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions changelogs/upcoming/7513.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ exports[`EuiTreeView is rendered 1`] = `
class="euiTreeView__node emotion-euiTreeView__node-default"
>
<button
aria-expanded="false"
class="euiTreeView__nodeInner emotion-euiTreeView__nodeInner-default"
data-test-subj="euiTreeViewButton-euiTreeView_generated-id"
id="item_a"
Expand Down Expand Up @@ -128,7 +127,6 @@ exports[`EuiTreeView is rendered 1`] = `
class="euiTreeView__node emotion-euiTreeView__node-default"
>
<button
aria-expanded="false"
class="euiTreeView__nodeInner emotion-euiTreeView__nodeInner-default"
data-test-subj="euiTreeViewButton-euiTreeView_generated-id"
id="item_two"
Expand Down
4 changes: 3 additions & 1 deletion src/components/tree_view/tree_view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 6b0cc92

Please sign in to comment.