Hi,
I seem to have a problem with the autocomplete control, and I'm not sure if it's a bug or if I'm doing something wrong in the code.
This is the code I'm using. The Autocomplete control is inside a custom component that opens up a dialog to the user:
<SfAutoComplete AllowCustom="false" TValue="string" @bind-Value="@SelectedUserInFileStatusAutocomplete" TItem="ListUserViewData" cssClass="template" Placeholder="Seleziona un utente" DataSource="UserFileStatusAutocompleteData">
<AutoCompleteTemplates TItem="ListUserViewData">
<ItemTemplate>
<div class="e-list-wrapper e-list-multi-line e-list-avatar">
<Avatar Path="@context.ProfilePicId" Class="e-avatar e-avatar-circle" Size="20"></Avatar>
<span class="e-list-item-header">@context.Username</span>
</div>
</ItemTemplate>
</AutoCompleteTemplates>
<AutoCompleteFieldSettings Value="Username"></AutoCompleteFieldSettings>
</SfAutoComplete>
Data structures:
string SelectedUserInFileStatusAutocomplete;
ObservableCollection<ListUserViewData> UserAutocompleteData;
class ListUserViewData : ICloneable
{
public string Username { get; set; }
public string UserId { get; set; }
public string Description { get; set; }
public string ProfilePicId { get; set; }
public bool IsCreator { get; set; }
public bool CanEdit { get; set; }
public bool CanApprove { get; set; }
public object Clone()
{
return this.MemberwiseClone();
}
}
As you can see, I set the "AllowCustom" property to false, because I need users to select a single valid item from the list.
The list is populated correctly and shows the items as expected.
The bug I'm facing is that, when an user clicks on a suggested item from the autocomplete list, the value is correctly selected in the control, but after that, if the user clicks outside of the control/the control loses focus, then the textbox is cleared and the placeholder appears.
This does only happen if the user clicks on the suggestion. If the user types the complete item value, then the value is selected correctly and it stays there even if the user clicks outside and changes focus.
In both cases, custom values are cleared out (but this is correct and working fine).
Thank you for your support.