-
Notifications
You must be signed in to change notification settings - Fork 8
Fix: NVDA announces "document" instead of "AI is analyzing..." status message #450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e4753f3
Initial plan
Copilot afcde37
Fix: Add live region for AI analyzing status message
Copilot 6ec65a2
Merge branch 'next' into copilot/fix-nvda-announcement-issue
tnaum-ms f3edb33
fix: remove unnecessary aria-live attribute from loading status text
tnaum-ms a7b61aa
Fix: Use aria-live="assertive" for keyboard activation announcements
Copilot 856a294
wip: preparing to work with useannoucer hook
tnaum-ms 2ec14b5
Merge branch 'next' into copilot/fix-nvda-announcement-issue
tnaum-ms 458be97
fix: using new useAnnounce hook
tnaum-ms 164f538
feat: add Announcer component for screen reader announcements
tnaum-ms be1b72a
refactor: replace useAnnounce hook with Announcer component for scree…
tnaum-ms 077971b
fix: update Announcer component politeness levels for screen reader a…
tnaum-ms 46bfbe8
fix: remove aria-hidden attribute from loading text in GetPerformance…
tnaum-ms File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
src/webviews/api/webview-client/accessibility/Announcer.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import * as React from 'react'; | ||
| import { useEffect, useRef, useState } from 'react'; | ||
|
|
||
| export interface AnnouncerProps { | ||
| /** | ||
| * When true, the message will be announced to screen readers. | ||
| * Announcement triggers on transition from false to true. | ||
| */ | ||
| when: boolean; | ||
|
|
||
| /** | ||
| * The message to announce to screen readers. | ||
| */ | ||
| message: string; | ||
|
|
||
| /** | ||
| * The politeness level of the announcement. | ||
| * - 'polite': Waits for the user to finish their current activity before announcing (default) | ||
| * - 'assertive': Interrupts the user immediately (use sparingly) | ||
| * @default 'polite' | ||
| */ | ||
| politeness?: 'polite' | 'assertive'; | ||
| } | ||
|
|
||
| /** | ||
| * A declarative component for screen reader announcements. | ||
| * | ||
| * Announces the message when `when` transitions from false to true. | ||
| * Uses ARIA live regions following WCAG 4.1.3 (Status Messages). | ||
| * | ||
| * @example | ||
| * ```tsx | ||
| * <Announcer when={isLoading} message={l10n.t('AI is analyzing...')} /> | ||
| * ``` | ||
| */ | ||
| export function Announcer({ when, message, politeness = 'polite' }: AnnouncerProps): React.ReactElement { | ||
| const [announcement, setAnnouncement] = useState(''); | ||
| const wasActiveRef = useRef(false); | ||
|
|
||
| useEffect(() => { | ||
| if (when && !wasActiveRef.current) { | ||
| // Transition to active - announce with delay for NVDA compatibility | ||
| setAnnouncement(''); | ||
| const timer = setTimeout(() => setAnnouncement(message), 100); | ||
| wasActiveRef.current = true; | ||
| return () => clearTimeout(timer); | ||
| } else if (!when) { | ||
| // Reset for next activation | ||
| wasActiveRef.current = false; | ||
| setAnnouncement(''); | ||
| } | ||
| return undefined; | ||
| }, [when, message]); | ||
|
|
||
| // Visually hidden but accessible to screen readers | ||
| return ( | ||
| <div | ||
| role="status" | ||
| aria-live={politeness} | ||
| aria-atomic="true" | ||
| style={{ | ||
| position: 'absolute', | ||
| width: '1px', | ||
| height: '1px', | ||
| padding: 0, | ||
| margin: '-1px', | ||
| overflow: 'hidden', | ||
| clip: 'rect(0, 0, 0, 0)', | ||
| whiteSpace: 'nowrap', | ||
| borderWidth: 0, | ||
| }} | ||
| > | ||
| {announcement} | ||
| </div> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 0 additions & 111 deletions
111
src/webviews/api/webview-client/accessibility/useAnnounce.tsx
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.