SettingsRow · a group named by its title, described by its line, so assistive tech says what each control sets
This commit is contained in:
1 file changed
+11
-2
+11
-2
@@ -1,8 +1,9 @@
|
|||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use gpui::{
|
use gpui::{
|
||||||
AnyElement, App, ElementId, FontWeight, IntoElement, ParentElement, RenderOnce, SharedString,
|
AnyElement, App, ElementId, FontWeight, InteractiveElement as _, IntoElement, ParentElement,
|
||||||
Styled, Window, div,
|
RenderOnce, Role, SharedString, StatefulInteractiveElement as _, Styled, Window, div,
|
||||||
|
prelude::FluentBuilder as _,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -179,7 +180,15 @@ impl SettingsRow {
|
|||||||
impl RenderOnce for SettingsRow {
|
impl RenderOnce for SettingsRow {
|
||||||
fn render(self, _: &mut Window, cx: &mut App) -> impl IntoElement {
|
fn render(self, _: &mut Window, cx: &mut App) -> impl IntoElement {
|
||||||
let theme = cx.theme();
|
let theme = cx.theme();
|
||||||
|
// The row names its control for assistive tech.
|
||||||
|
let id = SharedString::from(format!("settings-row-{}", self.title));
|
||||||
div()
|
div()
|
||||||
|
.id(id)
|
||||||
|
.role(Role::Group)
|
||||||
|
.aria_label(self.title.clone())
|
||||||
|
.when_some(self.description.clone(), |row, text| {
|
||||||
|
row.aria_description(text)
|
||||||
|
})
|
||||||
.flex()
|
.flex()
|
||||||
.flex_wrap()
|
.flex_wrap()
|
||||||
.items_center()
|
.items_center()
|
||||||
|
|||||||
Reference in new issue
Block a user