From 191f8abbcc4ff1d8851e3c2bb5c9b460be5591f4 Mon Sep 17 00:00:00 2001 From: Cyril Date: Fri, 6 Mar 2026 14:57:05 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BF=EF=B8=8F(frontend)=20improve=20chat?= =?UTF-8?q?=20a11y=20for=20screen=20readers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Chat messages announced via role="log" when open, toast+announce when closed. --- CHANGELOG.md | 1 + .../notifications/MainNotificationToast.tsx | 16 +++++++++++++++- .../src/features/rooms/livekit/prefabs/Chat.tsx | 7 ++++++- src/frontend/src/locales/de/notifications.json | 1 + src/frontend/src/locales/de/rooms.json | 3 ++- src/frontend/src/locales/en/notifications.json | 1 + src/frontend/src/locales/en/rooms.json | 3 ++- src/frontend/src/locales/fr/notifications.json | 1 + src/frontend/src/locales/fr/rooms.json | 3 ++- src/frontend/src/locales/nl/notifications.json | 1 + src/frontend/src/locales/nl/rooms.json | 3 ++- 11 files changed, 34 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b9e0110..fff8d12f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to - ♿️(frontend) sync html lang attribute with i18n for screen readers #1111 - ♿️(frontend) improve MoreLink a11y and UX on home page #1112 +- ♿(frontend) improve chat toast a11y for screen readers #1109 ## [1.10.0] - 2026-03-05 diff --git a/src/frontend/src/features/notifications/MainNotificationToast.tsx b/src/frontend/src/features/notifications/MainNotificationToast.tsx index 89e8e4be..758a1389 100644 --- a/src/frontend/src/features/notifications/MainNotificationToast.tsx +++ b/src/frontend/src/features/notifications/MainNotificationToast.tsx @@ -18,10 +18,15 @@ import { ANIMATION_DURATION, ReactionPortals, } from '@/features/rooms/livekit/components/ReactionPortal' +import { layoutStore } from '@/stores/layout' +import { PanelId } from '@/features/rooms/livekit/hooks/useSidePanel' +import { useScreenReaderAnnounce } from '@/hooks/useScreenReaderAnnounce' export const MainNotificationToast = () => { const room = useRoomContext() const { triggerNotificationSound } = useNotificationSound() + const { t } = useTranslation('notifications') + const announce = useScreenReaderAnnounce() const [reactions, setReactions] = useState([]) const instanceIdRef = useRef(0) @@ -41,12 +46,21 @@ export const MainNotificationToast = () => { }, { timeout: NotificationDuration.MESSAGE } ) + if (layoutStore.activePanelId !== PanelId.CHAT) { + announce( + t('chatMessageReceived', { + name: participant.name || t('defaultName'), + message: chatMessage.message, + }), + 'polite' + ) + } } room.on(RoomEvent.ChatMessage, handleChatMessage) return () => { room.off(RoomEvent.ChatMessage, handleChatMessage) } - }, [room, triggerNotificationSound]) + }, [room, triggerNotificationSound, announce, t]) const handleEmoji = (emoji: string, participant: Participant) => { if (!emoji || !Object.values(Emoji).includes(emoji as Emoji)) return diff --git a/src/frontend/src/features/rooms/livekit/prefabs/Chat.tsx b/src/frontend/src/features/rooms/livekit/prefabs/Chat.tsx index 981deeb7..90d43eb9 100644 --- a/src/frontend/src/features/rooms/livekit/prefabs/Chat.tsx +++ b/src/frontend/src/features/rooms/livekit/prefabs/Chat.tsx @@ -151,7 +151,12 @@ export function Chat({ ...props }: ChatProps) { minHeight={0} overflowY="scroll" > -