MahApps / MahApps.Metro

A framework that allows developers to cobble together a better UI for their own WPF applications with minimal effort.
https://mahapps.com
MIT License
9.3k stars 2.45k forks source link

Combobox has accessibility issue if IsEditable=True #3998

Open dmansergh opened 3 years ago

dmansergh commented 3 years ago

Describe the bug

'Accessibility Insights for Windows' is a tool used to test the accessibility of Windows applications. A WPF application with a MahApps ComboBox with IsEditable=True causes 'Accessibility Insights for Windows' to report: "The Name property of a focusable element must not be null."

If the WPF application does not use MahApps then 'Accessibility Insights for Windows' does not report any issues. If the ComboBox does not set IsEditable=True then 'Accessibility Insights for Windows' does not report any issues.

The failure includes a link to https://docs.microsoft.com/en-us/accessibility-tools-docs/items/wpf/edit_name?branch=master which suggests how this sort of error should be fixed.

I assume the failures is related to the PART_EditableTextBox part of the ComboBox style in MahApps.Metro\src\MahApps.Metro\Styles\Controls.ComboBox.xaml

Steps to reproduce

  1. Clone https://github.com/dmansergh/mahapps-test.git which contains my example code.
  2. Download 'Accessibility Insights for Windows' from https://accessibilityinsights.io/docs/en/windows/overview/
  3. Build ComboBoxTest.sln and run the application.
  4. In 'Accessibility Insights for Windows' select the 'Inspect' tab, set 'What to select' to 'Entire App'.
  5. Hover over the ComboBoxTest window and press the blue icon that appears in the top right corner.
  6. 'Accessibility Insights for Windows' reports failure for 'edit' part of ComboBox.

Expected behavior

'Accessibility Insights for Windows' should report no issues - like it does when not using MahApps or when IsEditable=False.

Actual behavior

'Accessibility Insights for Windows' reports a failure for the edit portion of the ComboBox: "The Name property of a focusable element must not be null."

Environment

MahApps.Metro version: v2.4.3
Windows build number: Win10 1909 [Version 10.0.18363.1198]
Visual Studio: 2019 16.4.6
Target Framework: .Net Core 3.1

Screenshots

combo failure combo failure2

dmansergh commented 3 years ago

I think this explains the following difference in Windows Narrator output when using my sample application:

beccamc commented 3 years ago

@dmansergh I encountered this issue too. I'm not using MahApps, so I don't know if this will help you, but using AutomationProperties.LabeledBy worked for me when AutomationProperties.Name didn't. If you're able to add a Label or TextBlock this might work for you.