Tree · the tree and its rows reach assistive tech: tree items with their name, level, selection and open state

This commit is contained in:
ZacharyZhang-NY committed 2026-10-07 13:11:16 -04:00
1 parent a9b30c7eab
commit dabc1eb4d2
2 files changed
+10 -4

No files matched your search

+3 -2
View File
@@ -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() {
+7 -2
View File
@@ -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))