Skip to content

Commit 8821a08

Browse files
Copilotayushjai19
andauthored
Fix Narrator silence on PipsPager page navigation (#2093)
## Fix Narrator announcement for PipsPager page changes - [x] Initialize TestPipsPager2 with NumberOfPages property - [x] Implement SelectedIndexChanged event handler for narrator announcements - [x] Use UIHelper.AnnounceActionForAccessibility for programmatic narrator announcements - [x] Enhance announcement format to include total page count - [x] Extract notification ID to a constant for maintainability - [x] Run code review to validate changes - [x] Run CodeQL security check ## Summary This PR fixes an accessibility issue where the Narrator screen reader remained silent when users clicked the Next/Previous page buttons on the PipsPager control in the WinUI 3 Gallery app. ### Changes Made: 1. **Initialized PipsPager**: Set NumberOfPages="10" on TestPipsPager2 to provide a working example 2. **Implemented event handler**: Added SelectedIndexChanged handler that uses `UIHelper.AnnounceActionForAccessibility()` to programmatically announce page changes to screen readers 3. **Enhanced announcement format**: Changed from "Page X selected" to "Page X of Y selected" to provide users with context about their position and the total number of pages 4. **Code quality improvement**: Extracted notification ID to a private constant (`PipsPagerPageChangeNotificationId`) for better maintainability and to prevent typos 5. **No visible UI changes**: Uses AutomationPeer.RaiseNotificationEvent internally (via UIHelper) to announce without adding visible text elements ### Technical Implementation: The solution uses `UIHelper.AnnounceActionForAccessibility()` which internally calls `AutomationPeer.RaiseNotificationEvent()` with `AutomationNotificationKind.ActionCompleted`. This approach follows the pattern used throughout the WinUI Gallery codebase (AppBarButtonPage, BreadcrumbBarPage, ClipboardPage, etc.) for making narrator announcements without requiring visible UI elements. ### Accessibility Impact: Users who rely on screen readers will now hear "Page X of Y selected" when navigating through pages using the Next/Previous buttons, meeting MAS 4.2.12 accessibility requirements, without any visible UI changes to the PipsPager control. The enhanced format provides better context by including the total page count. <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Upon selecting Next page/Previous page, Narrator remains silent</issue_title> > <issue_description>### Which version of the app? > > WinUI 3 Gallery > > ### Description > > Environment Details: > OS Version: 24H2 (OS Build 26100.4315) > App: WinUI 3 Gallery > App Version: 2.6.0.0 (SDK 1.7) > AT: Color Contrast > > Repro Steps: > Launch the WinUI 3 Gallery app. > Navigate to search box using tab key. > Type 'Pipspager' in search box and activate it. > Now navigate to 'Next/Previous page' button under 'Pipspager with options to change its orientation and button visibility'. And activate it. Observe Narrator announcement. > Actual Result: > Upon selecting Next page/Previous page, Narrator remains silent Instead of announcing the appeared page information and focused element information. > > Expected Result: > Upon selecting Next page/Previous page, Narrator should not remain silent, Instead it should announce the selected page Like, Page 5 selected. > > User impact: > Users who rely on Screen reader will face difficulty in understanding the updated page information. > > MAS Reference Link: [MAS 4.2.12 – Change Notification](https://aka.ms/MAS4.2.12) > > Trap ID: [1.9 - Feedback Failure](https://aka.ms/FeedbackFailure) > > “Have feedback on bugs logged, please tag bug as “A11yRCA” and add your feedback in the comment section.” > > ### Screenshots > > _No response_ > > ### Windows version > > Windows 11 24H2 (26100) > > ### Additional context > > _No response_</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes #2086 <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ayushjai19 <244442986+ayushjai19@users.noreply.github.com>
1 parent 18bdae8 commit 8821a08

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

WinUIGallery/Samples/ControlPages/PipsPagerPage.xaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@
5151
</controls:ControlExample>
5252
<controls:ControlExample x:Name="Example2" HeaderText="PipsPager with options to change its orientation and button visibility.">
5353
<controls:ControlExample.Example>
54-
<PipsPager x:Name="TestPipsPager2" />
54+
<PipsPager
55+
x:Name="TestPipsPager2"
56+
NumberOfPages="10"
57+
SelectedIndexChanged="TestPipsPager2_SelectedIndexChanged" />
5558
</controls:ControlExample.Example>
5659
<controls:ControlExample.Options>
5760
<StackPanel>

WinUIGallery/Samples/ControlPages/PipsPagerPage.xaml.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33

44
using Microsoft.UI.Xaml.Controls;
55
using System.Collections.Generic;
6+
using WinUIGallery.Helpers;
67

78
namespace WinUIGallery.ControlPages;
89

910
public sealed partial class PipsPagerPage : Page
1011
{
12+
private const string PipsPagerPageChangeNotificationId = "PipsPagerPageChangeNotificationId";
13+
1114
public List<string> Pictures = new List<string>()
1215
{
1316
"ms-appx:///Assets/SampleMedia/LandscapeImage1.jpg",
@@ -24,6 +27,14 @@ public PipsPagerPage()
2427
this.InitializeComponent();
2528
}
2629

30+
private void TestPipsPager2_SelectedIndexChanged(PipsPager sender, PipsPagerSelectedIndexChangedEventArgs args)
31+
{
32+
int pageNumber = sender.SelectedPageIndex + 1; // Convert 0-based index to 1-based page number
33+
int totalPages = sender.NumberOfPages;
34+
string announcement = $"Page {pageNumber} of {totalPages} selected";
35+
UIHelper.AnnounceActionForAccessibility(sender, announcement, PipsPagerPageChangeNotificationId);
36+
}
37+
2738
private void OrientationComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
2839
{
2940
string? orientation = e.AddedItems[0].ToString();

0 commit comments

Comments
 (0)