Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

danielchalmers
Copy link
Member

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (fix or improvement to the website or code docs)

Checklist

  • The PR is submitted to the correct branch (dev).
  • My code follows the code style of this project.
  • I've added relevant tests.

@danielchalmers danielchalmers requested a review from Anu6is June 11, 2025 17:14
@github-actions github-actions bot added the bug Unexpected behavior or functionality not working as intended label Jun 11, 2025
@danielchalmers
Copy link
Member Author

@beckerrobin let me know if this fix helps!

Copy link

Copy link

codecov bot commented Jun 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.14%. Comparing base (774ed5d) to head (02553e4).
Report is 7 commits behind head on dev.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@Copilot Copilot AI left a 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();

@danielchalmers danielchalmers merged commit 16bba75 into MudBlazor:dev Jun 12, 2025
7 checks passed
@danielchalmers danielchalmers deleted the fix-autocomplete-stealing-focus-back branch June 12, 2025 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected behavior or functionality not working as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MudAutocomplete async ValueChanged pulls back focus
3 participants