mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-20 01:18:10 +01:00
🎙️ a11y: Screen Reader Support for Dynamic Content Updates (#3625)
* WIP: first pass, hooks * wip: isStream arg * feat: first pass, dynamic content updates, screen reader announcements * chore: unrelated, styling redundancy
This commit is contained in:
parent
05696233a9
commit
6655304753
14 changed files with 353 additions and 54 deletions
28
client/src/Providers/AnnouncerContext.tsx
Normal file
28
client/src/Providers/AnnouncerContext.tsx
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// AnnouncerContext.tsx
|
||||
import React from 'react';
|
||||
|
||||
export interface AnnounceOptions {
|
||||
message: string;
|
||||
id?: string;
|
||||
isStream?: boolean;
|
||||
isComplete?: boolean;
|
||||
}
|
||||
|
||||
interface AnnouncerContextType {
|
||||
announceAssertive: (options: AnnounceOptions) => void;
|
||||
announcePolite: (options: AnnounceOptions) => void;
|
||||
}
|
||||
|
||||
const defaultContext: AnnouncerContextType = {
|
||||
announceAssertive: () => console.warn('Announcement failed, LiveAnnouncer context is missing'),
|
||||
announcePolite: () => console.warn('Announcement failed, LiveAnnouncer context is missing'),
|
||||
};
|
||||
|
||||
const AnnouncerContext = React.createContext<AnnouncerContextType>(defaultContext);
|
||||
|
||||
export const useLiveAnnouncer = () => {
|
||||
const context = React.useContext(AnnouncerContext);
|
||||
return context;
|
||||
};
|
||||
|
||||
export default AnnouncerContext;
|
||||
|
|
@ -11,3 +11,4 @@ export * from './BookmarkContext';
|
|||
export * from './DashboardContext';
|
||||
export * from './AssistantsContext';
|
||||
export * from './AssistantsMapContext';
|
||||
export * from './AnnouncerContext';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue