MCPcopy
hub / github.com/tomkp/react-split-pane / announce

Function announce

src/utils/accessibility.ts:5–31  ·  view source on GitHub ↗
(
  message: string,
  priority: 'polite' | 'assertive' = 'polite'
)

Source from the content-addressed store, hash-verified

3 * SSR-safe: no-op when document is not available.
4 */
5export function announce(
6 message: string,
7 priority: 'polite' | 'assertive' = 'polite'
8): void {
9 // SSR safety check
10 if (typeof document === 'undefined') {
11 return;
12 }
13
14 const announcement = document.createElement('div');
15 announcement.setAttribute('role', 'status');
16 announcement.setAttribute('aria-live', priority);
17 announcement.setAttribute('aria-atomic', 'true');
18 announcement.style.position = 'absolute';
19 announcement.style.left = '-10000px';
20 announcement.style.width = '1px';
21 announcement.style.height = '1px';
22 announcement.style.overflow = 'hidden';
23 announcement.textContent = message;
24
25 document.body.appendChild(announcement);
26
27 // Remove after announcement
28 setTimeout(() => {
29 document.body.removeChild(announcement);
30 }, 1000);
31}
32
33/**
34 * Format size for screen reader announcement

Callers 2

useKeyboardResizeFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…