CAMS-706 Fix NVDA screen reader announcement of alert titles#2000
Open
fmaddenflx wants to merge 8 commits intomainfrom
Open
CAMS-706 Fix NVDA screen reader announcement of alert titles#2000fmaddenflx wants to merge 8 commits intomainfrom
fmaddenflx wants to merge 8 commits intomainfrom
Conversation
Contributor
Reviewer's GuideImplements ARIA live region-friendly behavior for the Alert component so NVDA announces dynamically appearing alert titles, by changing how alerts are rendered, styled, and tested, and ensuring static errors show immediately. Sequence diagram for dynamic alert announcement with NVDAsequenceDiagram
actor User
participant AppComponent
participant Alert as Alert_component
participant DOM
participant NVDA as ScreenReader_NVDA
User->>AppComponent: Triggers action that causes error
AppComponent->>Alert: call show()
Alert->>Alert: set isVisible = True
Alert->>DOM: Render alert body with heading
Note over Alert,DOM: Heading has id headingId
Alert->>DOM: Set role=status or alert
Alert->>DOM: Set aria-live=polite/assertive
Alert->>DOM: Set aria-atomic=true
Alert->>DOM: Set aria-labelledby=headingId
DOM-->>NVDA: Live region content changed
NVDA-->>User: Announces alert title and message
User->>AppComponent: Dismiss or resolves condition
AppComponent->>Alert: call hide()
Alert->>Alert: set isVisible = False
Alert->>DOM: Remove alert body content (live region persists)
Class diagram for updated Alert component structureclassDiagram
direction LR
class AlertProps {
+string id
+string title
+string message
+UswdsAlertStyle type
+string role
+boolean slim
+boolean show
+ReactNode children
}
class AlertRefType {
+show() void
+hide() void
}
class Alert_ {
+useId() string autoId
-IsVisible isVisible
-string alertId
-string headingId
+show() void
+hide() void
+render() ReactElement
}
class IsVisible {
<<enum>>
True
False
Unset
}
AlertProps <.. Alert_ : uses
AlertRefType <.. Alert_ : implements
IsVisible <.. Alert_ : state
Alert_ : aria-live
Alert_ : aria-atomic = true
Alert_ : aria-labelledby = headingId when isVisible == True and title
Alert_ : renders body only when isVisible == True
Alert_ : container uses class visible for CSS visibility
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Improve screen reader announcement of alert titles when alerts appear dynamically. NVDA was not reading alert titles when alerts popped up on rendered screens. Changes: - Add aria-labelledby to link alert to its heading element - Add aria-atomic="true" to ensure complete alert content is announced - Auto-generate unique IDs using useId() hook when id prop not provided - Add test page at /test/alert-accessibility for manual NVDA testing - Add tests to verify aria attributes are correctly applied Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Change Alert to only render content when visible so that aria-live regions announce content changes. Screen readers only announce when content is added/changed within a live region, not when visibility changes. Changes: - Use visibility:hidden instead of display:none for alert container so aria-live region stays in DOM - Only render alert body content when isVisible === True - This triggers aria-live announcement because content actually changes in the live region Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Update Alert to render content when either:
- show() method is called (controlled mode with show prop)
- show prop is undefined (uncontrolled mode - always visible when rendered)
This allows alerts to work in both modes:
1. Controlled: <Alert ref={ref} show={false} /> then ref.current.show()
2. Uncontrolled: {error && <Alert>{error}</Alert>}
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Only render alert body content when isVisible is True. This ensures aria-live regions see actual content changes (not just visibility changes) and properly announce to screen readers.
Static alerts that should be immediately visible must now use show={true}.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
0a96b52 to
688ed5f
Compare
diabagatekelly
approved these changes
Feb 27, 2026
btposey
approved these changes
Feb 27, 2026
jamesobrooks
approved these changes
Feb 27, 2026
jalba-flexion
approved these changes
Mar 4, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixed accessibility issue where NVDA screen reader was not announcing alert titles when alerts appeared dynamically on the screen.
Problem
When an alert with a title popped up on an already-rendered screen, NVDA would not read the alert title. It would only read the title if the page loaded with the alert already visible and NVDA read the entire page.
Solution
Implemented proper ARIA live region support for dynamic alert announcements:
aria-labelledbyandaria-atomic="true"- Establishes semantic relationship between alert and heading, ensures complete content announcementuseId()hook to ensure unique IDs when not providedshow={true}to alerts that should display immediatelyTechnical Details
display: none/visibility: hiddentoopacity+z-indexfor visual hidingisVisible === True, creating actual DOM changes for aria-liveTest Plan
Definition of Done
🤖 Generated with Claude Code
Summary by Sourcery
Improve accessibility and visibility behavior of the Alert component for dynamically displayed messages.
New Features:
Bug Fixes:
Enhancements:
Tests: