AB#120092 Screen-reader fix fo data-only messages#269
Open
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Contributor
There was a problem hiding this comment.
Pull request overview
Adjusts the screen-reader live region behavior so “data-only” messages don’t trigger announcements in the Webchat UI accessibility layer.
Changes:
- Changed DOM text extraction fallback to return an empty string instead of announcing a generic default.
- Updated the live-region component to only announce when extracted content is non-empty (otherwise stay silent).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/webchat-ui/utils/live-region-announcement.ts | Returns empty string when no message DOM node is found (silence instead of generic fallback). |
| src/webchat-ui/components/presentational/ScreenReaderLiveRegion.tsx | Skips setLiveMessage when cleaned text is empty to avoid announcing data-only messages. |
Contributor
There was a problem hiding this comment.
Pull request overview
Adjusts the screen-reader live-region announcement logic in the Webchat UI to avoid announcing “data-only” (non-rendered) messages.
Changes:
- Updated
getTextFromDOMto return both extracted text and a flag indicating whether a matching DOM element was found. - Updated
ScreenReaderLiveRegionto suppress announcements when the message element is not found and to only announce non-empty content.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/webchat-ui/utils/live-region-announcement.ts | Changes getTextFromDOM to return { text, elementExists } instead of a plain string. |
| src/webchat-ui/components/presentational/ScreenReaderLiveRegion.tsx | Uses the new DOM lookup result to decide whether to announce, and suppresses empty announcements. |
Comment on lines
+66
to
+74
| const domResult = getTextFromDOM(id); | ||
| if (domResult.elementExists) { | ||
| // Element exists in DOM but may have no accessible text | ||
| // For visible elements without text (like images), provide a generic announcement | ||
| text = cleanUpText(domResult.text || "A new message"); | ||
| } else { | ||
| // Element doesn't exist - this is a data-only message that shouldn't be announced | ||
| text = ""; | ||
| } |
Comment on lines
+91
to
+93
| if (!messageElement) { | ||
| return { text: "", elementExists: false }; // Element doesn't exist - data-only message | ||
| } |
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.
Success criteria
Please describe what should be possible after this change. List all individual items on a separate line.
How to test
Please describe the individual steps on how a peer can test your change.
Security
Additional considerations
Documentation Considerations
These are hints for the documentation team to help write the docs.