Skip to content

Conversation

@sabareesanms
Copy link
Contributor

Bug: [WinUI 3 Gallery: Fundamentals-> Custom &user controls]: Screen reader fails to announce appeared suggestions to the user.

Description:
Custom password box in Custom & user controls page failed to announce suggestion via screen reader.

Fix:
The current design of the password suggestion box works with changing the visibility of the text blocks. However, this design doesn't allow the combined text to be provided for screen reader for announcements and also AutomationProperties.LiveSetting doesn't work with visibility change. So, the current design is migrated with RichEditTextBlock with AutomationProperties.LiveSetting for screen reader to announce the text changes in the password change event.

File Changes:

WinUIGallery/Samples/ControlPages/Fundamentals/Controls/ValidatedPasswordBox.cs
WinUIGallery/Samples/ControlPages/Fundamentals/Controls/ValidatedPasswordBox.xaml

Code Changes:

  • Switched from multiple visible StackPanel elements to a RichTextBlock
  • Added message builder for the RichTextBlock to display the validation messages along with the icons and text colors.
  • Added calls to FrameworkElementAutomationPeer.RaiseAutomationEvent(AutomationEvents.LiveRegionChanged) after validation updates to notify screen readers of content changes.
  • Fixed redundant event triggers causing duplicate narrator announcements by removing unwanted update calls.

Tests:
Tested the changes via NarratorBuddy and Narrator.

Screenshots:
Screenshot 2025-07-23 164721

@sabareesanms
Copy link
Contributor Author

/azp run

@sabareesanms sabareesanms enabled auto-merge (squash) July 23, 2025 13:09
@niels9001 niels9001 requested a review from Copilot July 23, 2025 15:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses a screen reader accessibility issue where password validation suggestions weren't being announced to users. The implementation replaces a visibility-based validation display system with a RichTextBlock that properly supports screen reader announcements through automation peers.

  • Migrated from multiple visible/hidden StackPanel elements to a single RichTextBlock with AutomationProperties.LiveSetting="Polite"
  • Added automation peer implementation to trigger LiveRegionChanged events for screen reader notifications
  • Removed redundant password change event handler that was causing duplicate announcements

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
ValidatedPasswordBox.xaml Replaced multiple validation StackPanels with a single RichTextBlock configured for screen reader support
ValidatedPasswordBox.cs Added RichTextBlock content building logic and automation peer event triggering for accessibility

Foreground = (Brush)Application.Current.Resources[resourceBrushKey]
});

paragraph.Inlines.Add(new LineBreak());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add linebreak only when adding a new line? Or else will it affect RichEditBox height?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We added newline here, so that the next added line will be added in new line rather than at the same line of the text.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the question is why we add newline before a new line coming in. We need to add it only at the point a newline getting added.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in this PR #1931

@sabareesanms
Copy link
Contributor Author

/azp run

@sabareesanms sabareesanms merged commit ddacfeb into main Jul 24, 2025
2 checks passed
@sabareesanms sabareesanms deleted the Bug_58168275_narrator_suggestion_issue branch July 24, 2025 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants