diff --git a/src/lists/tree/mod.rs b/src/lists/tree/mod.rs index 2bb7bfd..09458d8 100644 --- a/src/lists/tree/mod.rs +++ b/src/lists/tree/mod.rs @@ -8,8 +8,8 @@ use std::{collections::HashSet, rc::Rc}; use gpui::{ App, Div, ElementId, EntityId, InteractiveElement, IntoElement, ParentElement, RenderOnce, - ScrollStrategy, SharedString, StyleRefinement, Styled, UniformListScrollHandle, Window, div, - uniform_list, + Role, ScrollStrategy, SharedString, StatefulInteractiveElement, StyleRefinement, Styled, + UniformListScrollHandle, Window, div, uniform_list, }; pub(crate) use model::{Children, Shown, rows}; @@ -324,6 +324,7 @@ impl RenderOnce for Tree { .size_full(); self.base .id(self.id) + .role(Role::Tree) .track_focus(&focus) .on_key_down(move |event, window, cx| { if count == 0 || nav.read(cx).renaming.is_some() { diff --git a/src/lists/tree/row.rs b/src/lists/tree/row.rs index d1c1fd5..221a6cc 100644 --- a/src/lists/tree/row.rs +++ b/src/lists/tree/row.rs @@ -2,8 +2,8 @@ use std::{ops::Range, rc::Rc}; use gpui::{ AnyElement, App, DragMoveEvent, ElementId, Entity, EntityId, FocusHandle, InteractiveElement, - IntoElement, MouseButton, ParentElement, SharedString, StatefulInteractiveElement, Styled, - Window, div, prelude::*, relative, + IntoElement, MouseButton, ParentElement, Role, SharedString, StatefulInteractiveElement, + Styled, Window, div, prelude::*, relative, }; use super::{ @@ -171,6 +171,11 @@ fn row(rows: &Rows, ix: usize, window: &mut Window, cx: &mut App) -> AnyElement }; div() .id((rows.id.clone(), format!("node-{key}"))) + .role(Role::TreeItem) + .aria_label(label.clone()) + .aria_level(item.depth + 1) + .aria_selected(selected) + .when(opens, |row| row.aria_expanded(open)) .relative() .w_full() .h(theme.control_height(ControlSize::Md))