Skip to content

Modified custom password box implementation and added automation peer for narrator announcement. - #1930

Merged
sabareesanms merged 4 commits into
mainfrom
Bug_58168275_narrator_suggestion_issue
Jul 24, 2025
Merged

sabareesanms merged 4 commits into
mainfrom
Bug_58168275_narrator_suggestion_issue

Conversation

@sabareesanms

Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

/azp run

@sabareesanms
sabareesanms enabled auto-merge (squash) July 23, 2025 13:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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
Comment thread WinUIGallery/Samples/ControlPages/Fundamentals/Controls/ValidatedPasswordBox.cs Outdated
Foreground = (Brush)Application.Current.Resources[resourceBrushKey]
});

paragraph.Inlines.Add(new LineBreak());

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

/azp run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants