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::{
|
use gpui::{
|
||||||
App, Div, ElementId, EntityId, InteractiveElement, IntoElement, ParentElement, RenderOnce,
|
App, Div, ElementId, EntityId, InteractiveElement, IntoElement, ParentElement, RenderOnce,
|
||||||
ScrollStrategy, SharedString, StyleRefinement, Styled, UniformListScrollHandle, Window, div,
|
Role, ScrollStrategy, SharedString, StatefulInteractiveElement, StyleRefinement, Styled,
|
||||||
uniform_list,
|
UniformListScrollHandle, Window, div, uniform_list,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub(crate) use model::{Children, Shown, rows};
|
pub(crate) use model::{Children, Shown, rows};
|
||||||
@@ -324,6 +324,7 @@ impl RenderOnce for Tree {
|
|||||||
.size_full();
|
.size_full();
|
||||||
self.base
|
self.base
|
||||||
.id(self.id)
|
.id(self.id)
|
||||||
|
.role(Role::Tree)
|
||||||
.track_focus(&focus)
|
.track_focus(&focus)
|
||||||
.on_key_down(move |event, window, cx| {
|
.on_key_down(move |event, window, cx| {
|
||||||
if count == 0 || nav.read(cx).renaming.is_some() {
|
if count == 0 || nav.read(cx).renaming.is_some() {
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ use std::{ops::Range, rc::Rc};
|
|||||||
|
|
||||||
use gpui::{
|
use gpui::{
|
||||||
AnyElement, App, DragMoveEvent, ElementId, Entity, EntityId, FocusHandle, InteractiveElement,
|
AnyElement, App, DragMoveEvent, ElementId, Entity, EntityId, FocusHandle, InteractiveElement,
|
||||||
IntoElement, MouseButton, ParentElement, SharedString, StatefulInteractiveElement, Styled,
|
IntoElement, MouseButton, ParentElement, Role, SharedString, StatefulInteractiveElement,
|
||||||
Window, div, prelude::*, relative,
|
Styled, Window, div, prelude::*, relative,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
@@ -171,6 +171,11 @@ fn row(rows: &Rows, ix: usize, window: &mut Window, cx: &mut App) -> AnyElement
|
|||||||
};
|
};
|
||||||
div()
|
div()
|
||||||
.id((rows.id.clone(), format!("node-{key}")))
|
.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()
|
.relative()
|
||||||
.w_full()
|
.w_full()
|
||||||
.h(theme.control_height(ControlSize::Md))
|
.h(theme.control_height(ControlSize::Md))
|
||||||
|
|||||||
Reference in new issue
Block a user