From 3fcbd6f139015b056f60a0fd4a04ecb101b95ab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Thu, 8 Oct 2026 12:48:47 -0400 Subject: [PATCH] =?UTF-8?q?Toast=20=C2=B7=20an=20alert=20or=20status=20rol?= =?UTF-8?q?e=20named=20by=20its=20title,=20so=20screen=20readers=20hear=20?= =?UTF-8?q?every=20notice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/feedback/toast.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/feedback/toast.rs b/src/feedback/toast.rs index dd0c25d..185ffe3 100644 --- a/src/feedback/toast.rs +++ b/src/feedback/toast.rs @@ -3,7 +3,7 @@ use std::{rc::Rc, time::Duration}; use gpui::{ Anchor, Animation, AnimationExt, AnyElement, App, ClickEvent, Context, ElementId, Entity, FontWeight, HoverListenerMode, InteractiveElement, IntoElement, ParentElement, Pixels, - RenderOnce, SharedString, StatefulInteractiveElement, Styled, Task, Window, anchored, canvas, + RenderOnce, Role, SharedString, StatefulInteractiveElement, Styled, Task, Window, anchored, canvas, div, point, prelude::*, relative, }; use web_time::Instant; @@ -275,8 +275,16 @@ fn card( }; let theme = cx.theme(); let colors = &theme.colors; + // Read aloud: alerts interrupt, other notes wait their turn. + let role = match toast.severity { + Some(Severity::Danger | Severity::Warning) => Role::Alert, + _ => Role::Status, + }; let card = div() .id(key.clone()) + .role(role) + .aria_label(toast.title.clone()) + .when_some(toast.body.clone(), |card, body| card.aria_description(body)) .relative() .flex() .items_center()