Skip to content

Fix NVDA screen reader incorrect list count for File menu separators #2257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 10, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 9, 2025

Problem

When using NVDA screen reader to navigate the File menu, it incorrectly announces "1 of 9" instead of "1 of 6" for menu items. This happens because WPF separators are being counted as menu items in the accessibility tree.

Root Cause Analysis

The File menu contains:

  • 7 menu items (with one "Hide" item conditionally visible)
  • 2 separators
  • Total: 9 elements being announced by NVDA

However, users typically see only 6 items because:

  1. The "Hide" menu item is only visible when stack windows are open (controlled by CanHide method)
  2. Separators should not be counted as navigable menu items

Solution

Removed the separators and the Hide functionality as it's no longer relevant for newer versions of Windows. By default all PerfView windows show up under one button on the start-menu.

@Copilot Copilot AI changed the title [WIP] NVDA announces incorrect list count for "File" list – says "1 of 9" instead of "1 of 6" Fix NVDA screen reader incorrect list count for File menu separators Jul 9, 2025
@Copilot Copilot AI requested a review from brianrob July 9, 2025 18:54
Copilot finished work on behalf of brianrob July 9, 2025 18:54
@brianrob
Copy link
Member

brianrob commented Jul 9, 2025

This change fails to build with this error:

src\PerfView\MainWindow.xaml(82,32): Error MC3072: The property 'AutomationProperties.AccessibilityView' does not exist in XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation'. Line 82 Position 32.

Copy link
Contributor Author

Copilot AI commented Jul 9, 2025

This change fails to build with this error:

src\PerfView\MainWindow.xaml(82,32): Error MC3072: The property 'AutomationProperties.AccessibilityView' does not exist in XML namespace 'http://schem...

Fixed in commit e20bc9e. The issue was that AutomationProperties.AccessibilityView is not available in .NET Framework 4.6.2. I've replaced it with an alternative approach using properties that are available in .NET Framework 4.6.2:

  • IsTabStop="False" - Prevents tab navigation to separators
  • Focusable="False" - Prevents separators from receiving focus
  • AutomationProperties.Name="" - Clears the automation name
  • AutomationProperties.AutomationId="" - Clears the automation ID

This combination should help screen readers ignore the separators when counting menu items.

Copilot finished work on behalf of brianrob July 9, 2025 19:29
@brianrob
Copy link
Member

brianrob commented Jul 9, 2025

This change compiles, but still states that there are 9 items in the menu, where should only be 6 consumable items.

Copy link
Contributor Author

Copilot AI commented Jul 9, 2025

This change compiles, but still states that there are 9 items in the menu, where should only be 6 consumable items.

I've tried a more comprehensive approach in commit b9e740c using multiple accessibility properties available in .NET Framework 4.6.2:

  • IsTabStop="False" and Focusable="False" - Prevents navigation
  • IsEnabled="False" - Disables the separator entirely
  • AutomationProperties.IsKeyboardFocusable="False" - Excludes from keyboard navigation
  • AutomationProperties.IsContentElement="False" - Excludes from accessibility content view
  • AutomationProperties.Name="" - Clears automation name

This combination of properties should help screen readers properly ignore the separators when counting menu items. The approach targets different aspects of the accessibility tree that NVDA uses for navigation.

Copilot finished work on behalf of brianrob July 9, 2025 19:42
@brianrob
Copy link
Member

brianrob commented Jul 9, 2025

Copilot Post-Mortem:

  • Copilot really struggled with this one and could not get it right. It came up with solutions, but they either didn't compile or didn't work.
  • I also tried using VSCode Agent Mode with similar results.

Ultimately, I determined that removing the hidden items from the menu was a reasonable choice.

@brianrob brianrob marked this pull request as ready for review July 9, 2025 20:53
Copilot finished work on behalf of brianrob July 9, 2025 20:57
Copy link
Member

@mconnew mconnew left a comment

Choose a reason for hiding this comment

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

:shipit:

@brianrob brianrob merged commit 76b6938 into main Jul 10, 2025
6 checks passed
@brianrob brianrob deleted the copilot/fix-2256 branch July 10, 2025 22:27
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.

3 participants