-
Notifications
You must be signed in to change notification settings - Fork 362
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
fix: FluentAutocomplete does not have an ElementReference #1226
Comments
For anyone interested in the Foucs method, here is a workaround: public class MyAutoComplete<TOption> : FluentAutocomplete<TOption> where TOption : notnull
{
[Inject] private IJSRuntime JsRuntime { get; set; } = default!;
//only call after rendered (e.g. in OnAfterRender)
public async Task Focus()
{
ArgumentNullException.ThrowIfNull(Id);
await OnDropDownExpandedAsync();// this will open the menu
await JsRuntime.FocusElementById(Id);// this will focus the input
await InvokeAsync(StateHasChanged);// this will notify blazor that the element has changed
}
}
//...
public static class JsRuntimeExtensions
{
public static async Task FocusElementById(this IJSRuntime jsRuntime, string id)
{
var element = await jsRuntime.InvokeAsync<IJSObjectReference>("document.getElementById", id);
await element.InvokeVoidAsync("focus");
}
} and then in your razor file just use |
Hi Max, This isn't working at the moment because the
(Both |
Would be great to get milestones attached to issues to know when a given fix has shipped. Thanks! 🙏 |
Fix #1226: Add Element to AutoComplete TextField
🐛 Bug Report
I want to set focus on a
FluentAutocomplete
control. Unfortunately theElement
property won't be set correctly💻 Repro or Code Sample
🤔 Expected Behavior
It should create a valid
ElementReference
for theElement
Property😯 Current Behavior
No
ElementReference
will be set.Exception
💁 Possible Solution
It would be also nice and probably even better if
FluentAutocomplete
would implementFocusAsync
method like #157🌍 Your Environment
.net 8 and FluentUi 4.2.1
The text was updated successfully, but these errors were encountered: