Skip to content

Commit cbfc92f

Browse files
committed
♿️(frontend) announce ai status with aria-live
notify screen readers about ai thinking, writing, ready, or error
1 parent 6c30a23 commit cbfc92f

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

  • src/frontend/apps/impress/src/features/docs/doc-editor/components/AI

src/frontend/apps/impress/src/features/docs/doc-editor/components/AI/AIMenu.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,25 @@ export const AIMenu = (props: AIMenuProps) => {
195195
return t('Ask anything...');
196196
}, [aiResponseStatus, t]);
197197

198+
const ariaLiveMessage = useMemo(() => {
199+
if (aiResponseStatus === 'thinking') {
200+
return t('AI is thinking');
201+
}
202+
if (aiResponseStatus === 'ai-writing') {
203+
return t('AI is writing');
204+
}
205+
if (aiResponseStatus === 'user-reviewing') {
206+
return t('AI response ready for review');
207+
}
208+
if (aiResponseStatus === 'error') {
209+
return t('AI request failed');
210+
}
211+
212+
return '';
213+
}, [aiResponseStatus, t]);
214+
215+
const ariaLiveMode = aiResponseStatus === 'error' ? 'assertive' : 'polite';
216+
198217
const IconInput = useMemo(() => {
199218
if (aiResponseStatus === 'thinking') {
200219
return <IconAI width="24px" isLoading />;
@@ -256,6 +275,9 @@ export const AIMenu = (props: AIMenuProps) => {
256275
return (
257276
<Box className="--docs--ai-menu" $width="100%">
258277
<AIMenuStyle />
278+
<span className="sr-only" aria-live={ariaLiveMode} aria-atomic="true">
279+
{ariaLiveMessage}
280+
</span>
259281
<PromptSuggestionMenu
260282
onManualPromptSubmit={
261283
props.onManualPromptSubmit || onManualPromptSubmitDefault

0 commit comments

Comments
 (0)