-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
MudAutocomplete: Fix item selection stealing focus back after handler completes #11482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MudAutocomplete: Fix item selection stealing focus back after handler completes #11482
Conversation
@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:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
_handleNextFocus
flag 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();
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
).