-
Notifications
You must be signed in to change notification settings - Fork 459
Description
🐛 Bug Report
When using backspace within the FluentAutocomplete component the method bound to OnOptionsSearch will be executed twice. This results in my app crashing when using Entity Framework within the method to do a search.
I've also recorded a small video showcasing the issue:
https://github.com/user-attachments/assets/c842eb45-f26b-4b13-8c14-7a3d79dded23
💻 Repro or Code Sample
I've created a small sample repository here: https://github.com/MarvinKlein1508/FluentUI-autocomplete-twice
This is my code with EF:
private async Task OnSearchUsersAsync(OptionsSearchEventArgs<RecipientUser> e)
{
Log.Error("OnSearchUsersAsync");
await _userCts.CancelAsync();
_userCts = new CancellationTokenSource();
var token = _userCts.Token;
UserFilter filter = new UserFilter()
{
SearchPhrase = e.Text,
//Blocked = [.. Input!.Bearbeiter.Select(x => x.UserId)]
};
try
{
var users = await userService.GetAsync(DbContext, filter, token);
var bearbeiter = users.Items
.Select(u => new RecipientUser
{
UserId = u.UserId,
User = u,
})
.ToList();
e.Items = bearbeiter;
}
catch (OperationCanceledException)
{
}
}I'm using the DbContext object from my page to search for users within the database.
🤔 Expected Behavior
I would expect the emthod to only be executed once.
😯 Current Behavior
The method will be executed twice.
🔦 Additional information
This happens in both Blazor Server and WebAssembly for me. I've already tried to switch to the rendermodes with prerendering disabled.
🌍 Your Environment
- Browser Firefox, Edge, Chrome
- .NET and Fluent UI Blazor library Version [e.g. 9.0.2 and 1.11.4]