Tree · the tree and its rows reach assistive tech: tree items with their name, level, selection and open state
This commit is contained in:
2 files changed
+10
-4
No files matched your search
@@ -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() {
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in new issue
Block a user