AvaloniaUI / Avalonia.Controls.ItemsRepeater

ItemsRepeater is a light-weight control to generate and present a collection of items.
MIT License
2 stars 1 forks source link

Keyboard navigation issues when using ItemsRepeater #23

Open StefanKoell opened 8 months ago

StefanKoell commented 8 months ago

Describe the bug

In the provided sample, I'm using an ItemsRepeater and a nested ItemsRepeater to create multiple toggle buttons. The sample also has 2 toggle buttons created in XAML directly. Tabbing through the items allows me to tab through the XAML generated toggle buttons until I reach the first toggle button created by the ItemsRepeater. I can't tab to the other items.

Some additional observations:

To Reproduce

A simple repro case can be found here: https://github.com/StefanKoell/Misc/tree/main/src/AvaTabKeyIssue

  1. Start the app
  2. Hit the tab keys to cycle through the items
  3. Note that I can't reach items beyond the first one in the items repeater.

Expected behavior

When tabbing through the UI, I expect that all controls (with IsTabStop set to true) show the white focus adorner to allow keyboard interaction. I would also expect to cycle through all the items and show the white focus adorner using the accelerator key when multiple identical keys are assigned.

Environment

michalczerwinski commented 2 months ago

I ran into the same issue, multiple buttons in IteamRepeater makes it impossible to focus other then first one with the keyboard. The workaround is executing:

KeyboardNavigation.SetTabNavigation(ItemRepeater, KeyboardNavigationMode.Continue);

in the parent control. The root cause is "KeyboardNavigation.SetTabNavigation(this, KeyboardNavigationMode.Once)" is called in ItemRepeater ctor.

@maxkatz6: Is this something you would accept the PR for? Looks like the simple one, but I don't know the local rules...