Avalonia icon indicating copy to clipboard operation
Avalonia copied to clipboard

`ItemsPresenter` always sets `KeyboardInput.TabNavigation`

Open TomEdwardsEnscape opened this issue 3 years ago • 0 comments

Describe the bug These lines of code are executed by ItemsPresenter and so apply everwhere. But messing with the tab order only makes sense if the outer ItemsControl implements its own keyboard navigation, which is not always the case.

To Reproduce Paste this code into a XAML file and run it:

<StackPanel>
	<Button>Focusable control outside ItemsControl</Button>
	<ItemsControl>
		<TextBox/>
		<TextBox Text="Try tabbing to me"/>
	</ItemsControl>
</StackPanel>

Try to navigate between the two text boxes with the tab key

The first control can be focused, but the next tab press will will unexpectedly move focus to the button.

Expected behavior Pressing tab moves to the next control within the ItemsControl, exactly as if it had been created as a direct child of a panel.

Desktop (please complete the following information):

  • OS: Windows 10
  • Version 11 preview 2

Additional context This issue can be worked around by creating an ItemsControl template and explicitly setting KeyboardInput.TabNavigation on the ItemsPresenter within it.

TomEdwardsEnscape avatar Oct 24 '22 09:10 TomEdwardsEnscape