[Bug] SelectedTemplate does not show when value set outside of the control
Describe the bug After update from 4.5.1 to 4.6.0 content of the control stopped to refresh when value is initially null and then is changed outside of the control. The IsShowingMask is initially set to false if the value is null during OnInitialized and it can be set to true only in the Initialize method. The Initialize in the previous version was called in OnParametersSet which now was removed and component stopped to respond to StateHasChanged invoked from parent.
To Reproduce
- Place two Typeahead controls operating on values of the same type (value1 and value2),
- In the ValueChanged event handler of the first control set: value1 = selectedValue; value2 = selectedValue;
- In version 4.5.1 when I select a value from the first Typeahead it is shown in both,
- In 4.6 the new value is not shown in the second Typeahead.
Expected behavior A component should be kept synchronized with the value.
Hosting Model (is this issue happening with a certain hosting model?):
- Blazor WebAssembly
@chrissainty no comment?
@kamranghamsari This requires some investigation and I don't have any free time for this right now. Feel free to look into it and propose a solution.
I had time to see the samples closely there was no sample with ValueChanged event handler but you should use bind-value instead of Value and not use the ValueChanged event handler I'm sorry it's not much I will find a proper solution @chrissainty @askolniak
I have the same issue.
Hey, I encountered the same issue. I bypassed it by doing the following:
-
@bind-Value to a encapsulated object, with @ref to BlazoredTypeahead
<BlazoredTypeahead @ref="TypeAhead" id="taskId" placeholder="Choose Task" MaximumSuggestions="50" SearchMethod="SearchWorkItems" @bind-Value="SelectedTask" EnableDropDown="true"> -
Declared TypeAhead prop in the component
private BlazoredTypeahead<BaseWorkItem, BaseWorkItem> TypeAhead { get; set; } -
On object update:
public BaseWorkItem SelectedTask
{
get => _selectedTask;
set
{
_selectedTask = value;
if (TypeAhead is not null)
{
TypeAhead.Value = _selectedTask;
TypeAhead.ResetControlBlur().GetAwaiter();
StateHasChanged();
}
TaskUpdated.InvokeAsync().GetAwaiter();
StateHasChanged();
}
}