MCPcopy Create free account
hub / github.com/codeaashu/claude-code / LiveRegion

Function LiveRegion

web/components/a11y/LiveRegion.tsx:19–55  ·  view source on GitHub ↗
({ message, politeness = "polite" }: LiveRegionProps)

Source from the content-addressed store, hash-verified

17 * Clears after 500 ms to ensure repeated identical messages are re-announced.
18 */
19export function LiveRegion({ message, politeness = "polite" }: LiveRegionProps) {
20 const [announced, setAnnounced] = useState("");
21 const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
22
23 useEffect(() => {
24 if (!message) return;
25
26 // Clear first to force re-announcement of identical messages
27 setAnnounced("");
28 timerRef.current = setTimeout(() => setAnnounced(message), 50);
29
30 return () => {
31 if (timerRef.current) clearTimeout(timerRef.current);
32 };
33 }, [message]);
34
35 return (
36 <div
37 role="status"
38 aria-live={politeness}
39 aria-atomic="true"
40 style={{
41 position: "absolute",
42 width: "1px",
43 height: "1px",
44 padding: 0,
45 margin: "-1px",
46 overflow: "hidden",
47 clip: "rect(0, 0, 0, 0)",
48 whiteSpace: "nowrap",
49 borderWidth: 0,
50 }}
51 >
52 {announced}
53 </div>
54 );
55}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected