dotnet / dotnet/maui

[Accessibility] Windows CollectionView Keyboard Navigation

Open
#27,622 1 comment 0 reactions 2 assignees Claimed by @jsuarezruiz View on GitHub
area-controls-collectionview platform/windows s/triaged t/a11y t/bug t/desktop
Dominant language
C#
Stars
23.3k
Forks
2k
Avg merge
1d 14h
Merged PRs (30d)
296

Description

### Description

On Windows, navigating between items in a CollectionView with a hardware keyboard is pretty tricky. On Catalyst, this happens by default but Windows requires us to add a platform specific flag on the Windows CollectionView handler: SingleSelectionFollowsFocus.

If we do not set this flag, interacting with the keyboard on the Windows CollectionView gives us the following behavior:
* SelectionMode == None: we can navigate between the items but cannot select anything with the keyboard
* SelectionMode == Single: we can focus the first item and can select that item. If we use the arrow keys to traverse, it will select the second item. There is no way to just focus the second item and no way to focus or select any items after that.
* SelectionMode == Multiple: we can navigate and select any items.

This is something to monitor as we look into changes to the CollectionView for Windows in .NET10

### Steps to Reproduce

1. Create a MAUI project
2. Create a CollectionView
3. Populate the CollectionView Items
4. Run the project
5. Try to navigate through the items with the hardware keyboard and inspect the results

### Link to public reproduction project repository

_No response_

### Version with bug

9.0.30 SR3

### Is this a regression from previous behavior?

No, this is something new

### Last version that worked well

Unknown/Other

### Affected platforms

Windows

### Affected platform versions

_No response_

### Did you find any workaround?

Doing the following in the MauiProgram.cs allows us to traverse and select one item:

```cs
.ConfigureMauiHandlers(_ =>
{
Microsoft.Maui.Controls.Handlers.Items.CollectionViewHandler.Mapper.AppendToMapping("KeyboardAccessibleCollectionView", (handler, view) =>
{
#if WINDOWS
handler.PlatformView.SingleSelectionFollowsFocus = false;
#endif
});
});
```

### Relevant log output

```shell

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.