microsoft-ui-xaml
microsoft-ui-xaml copied to clipboard
`TextBox` inside a `ScrollViewer` does not lose focus when click in empty spaces
Describe the bug
TextBox inside a ScrollViewer does not lose focus when click in empty spaces, but a TextBox inside any other panel does.
Steps to reproduce the bug
- Use this xaml
<Grid Margin="50">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ScrollViewer Background="Red">
<TextBox
Width="500"
VerticalAlignment="Center"
PlaceholderText="This TextBox inside ScrollViewer does not lose focus when click in the red area" />
</ScrollViewer>
<Grid Grid.Column="1" Background="Blue">
<TextBox
Width="500"
VerticalAlignment="Center"
PlaceholderText="This TextBox inside Grid lose focus when click in the blue area" />
</Grid>
</Grid>
Expected behavior
No response
Screenshots
NuGet package version
Windows version
No response
Additional context
Related #3825 Repro
@codendone This is really an inconvenient issue :-|
I suspect the problem is the fix for #597 (internal bug), which added this code. Marking the PointerReleased as handled is probably preventing the unfocusing (which I think may be moving focus to the root visual).
Setting IsTabStop="true" on the ScrollViewer will allow the ScrollViewer to instead take focus in this situation, which may or may not be an improvement.