Fix: Add accessible name to Shortcut Conflicts button for screen readers (#42441)

## Summary
Fixes the accessibility issue where the "Shortcut Conflicts" button in
the Dashboard page has no accessible name defined, causing screen
readers to announce it as just "button" instead of providing context
about its purpose.

## Problem
The button in `ShortcutConflictControl.xaml` lacked an
`AutomationProperties.Name` attribute, violating WCAG 2.2 guidelines
(4.1.2 - Name, Role, Value). This prevented users who rely on screen
readers from determining the function of the button, making it
impossible to resolve or view shortcut conflicts.

**Before fix:**
- Screen reader announces: "button" 

**After fix:**
- Screen reader announces: "Shortcut conflicts, No conflicts found,
button" 
- Or: "Shortcut conflicts, 1 conflict found, button" 
- Or: "Shortcut conflicts, 3 conflicts found, button" 

## Solution
Added a new `AccessibleName` property to
`ShortcutConflictControl.xaml.cs` that combines:
- The static localized title: "Shortcut conflicts"
- The dynamic status text: "No conflicts found", "1 conflict found", or
"X conflicts found"

The button's `AutomationProperties.Name` is now bound to this property
using `{x:Bind AccessibleName, Mode=OneWay}`, ensuring it updates
dynamically as conflict data changes.

## Changes
- **ShortcutConflictControl.xaml**: Added `AutomationProperties.Name`
binding to the button
- **ShortcutConflictControl.xaml.cs**: Added `AccessibleName` property
and property change notification

## Impact
- Provides full context to assistive technology users about the button's
purpose and current state
- Complies with WCAG 2.2 accessibility standards
- Follows existing patterns in the codebase for accessible controls
- Minimal changes (2 files, 14 lines added)

## Related Issue
Closes #issue_number

## Testing
- [x] Code review completed with no issues
- [x] Follows existing accessibility patterns used in DashboardPage.xaml
- [x] Uses existing localized resource strings
- [x] Property updates dynamically via INotifyPropertyChanged

<!-- START COPILOT CODING AGENT SUFFIX -->



<details>

<summary>Original prompt</summary>

> 
> ----
> 
> *This section details on the original issue you should resolve*
> 
> <issue_title>No Accessible Name Defined for "Shortcut Conflicts"
Button.</issue_title>
> <issue_description>### Microsoft PowerToys version
> 
> v0.94.2
> 
> ### Installation method
> 
> PowerToys auto-update
> 
> ### Area(s) with issue?
> 
> New+
> 
> ### Steps to reproduce
> 
> **Repro Steps:**
> 
> 1. Open power toys.
> 2. Now navigate to the home section and select.
> 3. Now turn on narrator using CTRL + Win + Enter.
> 4. Now navigate to the Shortcut conflicts button.
> 5. Observe the narrator's announcement.
> 
> ### ✔️ Expected Behavior
> 
> The button should have an accessible name — either via a visible
label, aria-label, or aria-labelledby — so that assistive technology
users understand its purpose.
> 
> ###  Actual Behavior
> 
> The "Shortcut Conflicts" button has no accessible name defined. Screen
readers announce it as “button”.
> 
> ### Additional Information
> 
> **User Impact:**
> Users who rely on screen readers cannot determine the function of the
button, making it inaccessible. This prevents users from resolving or
viewing shortcut conflicts, which could impact usability and task
completion.
> 
> **WCAG Reference:**
> https://www.w3.org/WAI/WCAG22/Understanding/name-role-value
> 
> **Attachments:**
> 
>
https://github.com/user-attachments/assets/ca0f51d3-f736-4eb9-b355-e55f2cfd5bbd
> 
> ### Other Software
> 
> _No response_</issue_description>
> 
> ## Comments on the Issue (you are @copilot in this section)
> 
> <comments>
> </comments>
> 


</details>

Fixes microsoft/PowerToys#42418

<!-- START COPILOT CODING AGENT TIPS -->
---

 Let Copilot coding agent [set things up for
you](https://github.com/microsoft/PowerToys/issues/new?title=+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: niels9001 <9866362+niels9001@users.noreply.github.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
This commit is contained in:
Copilot
2025-11-06 18:07:48 +08:00
committed by GitHub
parent 5c96cea31f
commit 4a5e476a4e
2 changed files with 14 additions and 1 deletions

View File

@@ -9,7 +9,10 @@
mc:Ignorable="d">
<Grid>
<Button Click="ShortcutConflictBtn_Click" Style="{StaticResource SubtleButtonStyle}">
<Button
AutomationProperties.Name="{x:Bind AccessibleName, Mode=OneWay}"
Click="ShortcutConflictBtn_Click"
Style="{StaticResource SubtleButtonStyle}">
<Grid ColumnSpacing="16">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />

View File

@@ -88,6 +88,15 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
}
}
public string AccessibleName
{
get
{
var title = ResourceLoader.GetString("ShortcutConflictControl_Title");
return $"{title}, {ConflictText}";
}
}
public bool HasConflicts => ConflictCount > 0;
private static void OnAllHotkeyConflictsDataChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
@@ -104,6 +113,7 @@ namespace Microsoft.PowerToys.Settings.UI.Controls
{
OnPropertyChanged(nameof(ConflictCount));
OnPropertyChanged(nameof(ConflictText));
OnPropertyChanged(nameof(AccessibleName));
OnPropertyChanged(nameof(HasConflicts));
// Update visibility based on conflict count