Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): screen readers hear which background thread finished, even with the sidebar collapsed #23839

Mergedshivamhwp(GitHub profile, opens in a new tab)merged 10 commits intomain fromrefs/pull/23839/headmerged by shivamhwp(GitHub profile, opens in a new tab) View on GitHub

Showing 9 changed files with 27 additions and 30 deletions (loading 6).

x
0 of 9 viewed, 9 left
8 additions and 16 deletionsapps/web/src/components/chat/ThreadActivityAnnouncer.tsxModified
View file
@@ -1,15 +1,14 @@
import { memo, useEffect, useRef } from "react";
​
+import { useLiveRegion } from "../../hooks/useLiveRegion";
+​
import {
nextThreadAnnouncement,
type ThreadActivitySnapshot,
type ThreadAnnouncementMemory,
} from "./threadActivityAnnouncement";
​
-/**
- * One polite live region for the open thread. Text is written straight to the
- * DOM so an announcement never re-renders the timeline.
- */
+/** One polite live region for the open thread. */
export const ThreadActivityAnnouncer = memo(function ThreadActivityAnnouncer({
threadKey,
status,
@@ -23,14 +22,13 @@
/** See isDetailBehindShell. */
readonly detailBehind: boolean;
}) {
- const regionRef = useRef<HTMLDivElement>(null);
+ const { regionRef, announce, clear } = useLiveRegion();
const memoryRef = useRef<{ threadKey: string; memory: ThreadAnnouncementMemory } | null>(null);
​
useEffect(() => {
- const region = regionRef.current;
if (threadKey === null) {