Skip to content

Fix AutoCompleteBox popup not closing on focus lost - #21749

Merged
MrJul merged 2 commits into
AvaloniaUI:mainfrom
MrJul:fix/autocompletebox-focus-lost
Jul 10, 2026
Merged

Fix AutoCompleteBox popup not closing on focus lost#21749
MrJul merged 2 commits into
AvaloniaUI:mainfrom
MrJul:fix/autocompletebox-focus-lost

Conversation

@MrJul

@MrJul MrJul commented Jul 10, 2026

Copy link
Copy Markdown
Member

What does the pull request do?

This PR makes sure that the popup of an AutoCompleteBox closes when it loses focus.
A unit test has been added.

What is the current behavior?

The popup stays open after losing the focus.

What is the updated/expected behavior with this PR?

The popup correctly closes.

How was the solution implemented (if it's not obvious)?

AutoCompleteBox had a lot of convoluted code and comments dating back 8+ years regarding focus management that are no longer accurate. With the recent changes in focus management in Avalonia 12, the code was just wrong.

GotFocus/LostFocus are now the sources of truth, matching TextBox and ComboBox.

@MrJul MrJul added bug backport-candidate-12.1.x Consider this PR for backporting to 12.1 branch labels Jul 10, 2026

@timunie timunie left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks much better now overall.

@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.2.999-cibuild0067400-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@MrJul
MrJul added this pull request to the merge queue Jul 10, 2026
Merged via the queue into AvaloniaUI:main with commit 984b642 Jul 10, 2026
11 checks passed
@MrJul
MrJul deleted the fix/autocompletebox-focus-lost branch July 10, 2026 13:35
MrJul added a commit that referenced this pull request Jul 29, 2026
* Add failing test for AutoCompleteBox

* Fix AutoCompleteBox popup not closing on focus lost
@MrJul MrJul added backported-12.1.x and removed backport-candidate-12.1.x Consider this PR for backporting to 12.1 branch labels Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants