MudAutocomplete: Fix item selection stealing focus back after handler completes#11482
Merged
danielchalmers merged 1 commit intoMudBlazor:devfrom Jun 12, 2025
Conversation
Member
Author
|
@beckerrobin let me know if this fix helps! |
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #11482 +/- ##
==========================================
- Coverage 91.15% 91.14% -0.02%
==========================================
Files 466 466
Lines 14453 14470 +17
Branches 2800 2802 +2
==========================================
+ Hits 13175 13188 +13
- Misses 641 643 +2
- Partials 637 639 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Anu6is
approved these changes
Jun 11, 2025
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a focus issue in MudAutocomplete by ensuring the input regains focus before executing the option selection logic, preventing the component from stealing back focus after a long-running handler.
- Reordered
SelectOptionAsync(item)to run after setting focus - Ensured
_handleNextFocusflag is set once, before focusing - Minor formatting adjustment (blank line added)
Comments suppressed due to low confidence (1)
src/MudBlazor/Components/Autocomplete/MudAutocomplete.razor.cs:1203
- Consider adding a unit or integration test to verify that the input is focused before the selection logic executes, ensuring this focus-behavior fix doesn’t regress in the future.
await FocusAsync();
versile2
approved these changes
Jun 12, 2025
This was referenced Aug 1, 2025
Closed
This was referenced Aug 14, 2025
This was referenced Aug 25, 2025
This was referenced Dec 12, 2025
Closed
Closed
This was referenced Dec 29, 2025
This was referenced Jan 9, 2026
Closed
This was referenced Feb 10, 2026
Closed
This was referenced Feb 23, 2026
This was referenced Mar 9, 2026
This was referenced Mar 16, 2026
This was referenced Apr 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
Fixes #11473.
We were previously focusing the input AFTER handling the option selected logic, meaning that a lengthy handler would cause the component to steal the focus back after it's finished. Now we give it focus BEFORE so it only has it immediately after choosing the option and closing the menu.
How Has This Been Tested?
visually
Type of Changes
Checklist
dev).