Repository navigation
Keep focus in the text box when an AutoCompleteBox item is picked - #22356
Conversation
NuGet packagesThe packages for this pull request have been published (workflow run):
|
MrJul
left a comment
There was a problem hiding this comment.
I don't think this is the right approach.
For comparison, ComboBox items are focusable, and we should keep the same behavior here. I'm also worried about the impact on accessibility and automation, but I haven't tested them yet.
This PR introduces a real regression: touch/pen don't close the box anymore. This seems to be actually a pre-existing bug that was previously hidden by the focus change, so in the end it worked.
In addition, if there's any focusable control in the container itself from an item template (a niche scenario, I admit), the fix won't work. We need a more general solution here.
|
Sure, I changed the approach. The real problem was that |
…2356) * Add a test for AutoCompleteBox drop-down items not taking focus * Keep focus in the text box when an AutoCompleteBox item is picked * Keep the pointer handler's doc comment with its method * Simplify comment * Add test * Keep the drop-down open while focus is inside it --------- Co-authored-by: Julien Lebosquain <julien@lebosquain.net>
What does the pull request do?
Keeps the
AutoCompleteBoxdrop-down open while focus is inside it, so picking an item with the mouse commits the item.What is the current behavior?
The drop-down is its own popup, so pressing an item moves focus into it.
OnLostFocuscloses the popup immediately, which meansPointerReleasednever reaches the selector and the commit never runs. The text box shows the picked item, but focus never returns to it, so aTextbinding withUpdateSourceTrigger=LostFocusis left holding whatever was typed before the click.Picking with the keyboard works, because focus stays in the text box the whole time.
What is the updated/expected behavior with this PR?
OnLostFocusignores focus moving into the drop-down, so the popup stays open until the item is committed. Items keep their normal focus behaviour and pointer handling is untouched.Checklist
Fixed issues
Fixes #22246