Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 30, 2025

This PR fixes an accessibility issue where the "Uniform grid" and "Custom virtualizing layout" radio buttons in the ItemsRepeater sample page had incorrect keyboard navigation behavior.

Problem

The radio buttons were implemented as individual RadioButton elements with Click handlers, which caused both Tab and Arrow key navigation to work within the same group. This violated accessibility guidelines and confused keyboard users who expected:

  • Tab key to move focus into/out of the radio group
  • Arrow keys to navigate within the group and auto-select items
  • No Space key requirement for selection

Solution

Replaced the individual RadioButton elements with a RadioButtons control:

Before:

<RadioButton Click="LayoutBtn_Click" Content="Uniform grid" GroupName="Sample2Layouts" Tag="UniformGridLayout2" />
<RadioButton Click="LayoutBtn_Click" Content="Custom virtualizing layout" GroupName="Sample2Layouts" IsChecked="True" Tag="MyFeedLayout" />

After:

<RadioButtons SelectedIndex="1" SelectionChanged="LayoutBtn_SelectionChanged">
    <RadioButton Content="Uniform grid" Tag="UniformGridLayout2" />
    <RadioButton Content="Custom virtualizing layout" Tag="MyFeedLayout" />
</RadioButtons>

Updated the corresponding C# event handler to use SelectionChangedEventArgs and get the selected item from the RadioButtons control while maintaining all existing layout switching functionality.

Benefits

  • ✅ Proper keyboard navigation (Tab moves between groups, Arrow keys within groups)
  • ✅ Auto-selection with arrow keys (no Space key required)
  • ✅ Follows WinUI accessibility guidelines
  • ✅ Consistent with other RadioButtons usage in the Gallery
  • ✅ Improved experience for keyboard-only users

Fixes #1943.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • e7bvsblobprodcus348.vsblob.vsassets.io
    • Triggering command: dotnet restore WinUIGallery.sln (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: niels9001 <9866362+niels9001@users.noreply.github.com>
Copilot AI changed the title [WIP] [WinUI 3 Gallery: Collections->ItemsRepeater]: Both tab and arrow navigation has been defined for 'Uniform grid' & 'Custom virtualizing layout' radio buttons Fix RadioButton keyboard navigation in ItemsRepeater layout options Jul 30, 2025
Copilot AI requested a review from niels9001 July 30, 2025 15:29
Copy link
Collaborator

@niels9001 niels9001 left a comment

Choose a reason for hiding this comment

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

LGTM! Tested, and it works! Amazing!

@niels9001 niels9001 marked this pull request as ready for review July 30, 2025 16:33
@marcelwgn marcelwgn enabled auto-merge (squash) July 30, 2025 18:09
@marcelwgn
Copy link
Contributor

/azp run

@marcelwgn
Copy link
Contributor

/azp run

@marcelwgn marcelwgn merged commit 30361cd into main Jul 31, 2025
2 checks passed
@marcelwgn marcelwgn deleted the copilot/fix-1943 branch July 31, 2025 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants