UIA: Multiple (redundant) AutomationFocusChange events sent when opening a context menu
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
* .NET Core Version: 6.0.100-preview.7.21328.6, targeting 3.1
* Windows version: Windows 10 21H1
* Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes
* Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)? No
**Problem description:**
When opening a context menu in WPF, multiple UIA `AutomationFocusChanged` events are often fired. This causes some accessibility tools (like NVDA) to announce the menu multiple times.
**Actual behavior:**
Most of the times, 2 `AutomationFocusChanged` events are fired. Sometimes there is only 1 and sometimes there are 3.
**Expected behavior:**
1 `AutomationFocusChanged` event should be consistently fired when the menu opens
**Minimal repro:**
1. Clone the sample repo `git clone https://github.com/DaveTryon/wpf-context-menu-sample.git`
2. Build the project in Visual Studio
3. Run [NVDA](https://www.nvaccess.org/)
4. Launch the sample app
5. Open the context menus--one opens when the upper button is pressed, the other opens on right-click on the lower button
6. Notice how many times NVDA announces "Menu"
If you use Accessibility Insights to capture the UIA events, you can confirm that multiple `AutomationFocusChanged` events are being sent multiple times. NVDA announces on each event. One could argue that NVDA ought to filter multiple events, but it makes more sense for WPF not to send the multiple events in the first place.
Contributor guide
Assessment
This issue has not been assessed yet.