-
-
Notifications
You must be signed in to change notification settings - Fork 103
Typeahead search text dissapearing from search box after displaying results in v 4.7.0 #288
Comments
Have you seen the discussion here? Others have reported similar issues but it's always turned out to be a fix in their code base. |
@chrissainty I have same issue after updating Blazored.Modal from 6.0.1 to 7.0.0 right now. Typeahead was 4.7.0 for long time and worked good. |
I can confirm this issue occurs together with Blazored.Modal 7.0.0. I am unable to type text in the Typeahead box as the characters I type/paste are immediately removed.
Edit: I cannot reproduce it in a minimal reproduction sample. I will follow up by rechecking the (updated?) package setup requirements and further stripping down my solution. I also suspect it has something to do with the solution template initially started with .net5 and I might have missed an upgrade step. |
Can confirm I see the same issue with Blazored.Modal 7.0.0 and Typeahead 4.7.0. I don't know if I started from net5.0 template anymore but I am going to check the. I did some more digging. Compared my app to the net6.0 blazor Server app template and found no significant differences besides what I added for my app. Will try to copy my code into a clean repo and see if it works then... |
I could actually narrow it down to the <h3>ModalWithTypeahead</h3>
<BlazoredTypeahead @bind-Value=PersonSelected SearchMethod=SearchPeople placholder="Search by name...">
<SelectedTemplate Context=person>
@person?.Firstname @person?.Lastname
</SelectedTemplate>
<ResultTemplate Context=person>
@person.Firstname @person.Lastname
</ResultTemplate>
</BlazoredTypeahead>
<BlazoredTypeahead @bind-Values=PeopleSelected SearchMethod=SearchPeople placeholder="Search by name ...">
<SelectedTemplate Context=person>
@person.Firstname @person.Lastname
</SelectedTemplate>
<ResultTemplate Context=person>
@person.Firstname @person.Lastname
</ResultTemplate>
</BlazoredTypeahead>
@code {
[CascadingParameter]
public BlazoredModalInstance? ModalInstance { get; set; }
private IEnumerable<Person> PeopleAvaialable { get; set; } = Array.Empty<Person>();
private Person? PersonSelected { get; set; }
private IList<Person> PeopleSelected { get; set; } = new List<Person>();
protected override void OnInitialized()
{
var people = new List<Person>();
for (int i=0; i<10; i++)
{
people.Add(new() { Firstname = "Person", Lastname = $"Number{i + 1}" });
}
PeopleAvaialable = people;
}
private Task<IEnumerable<Person>> SearchPeople(string searchString)
{
return Task.FromResult(PeopleAvaialable
.Where(x => x.Firstname.Contains(searchString) || x.Lastname.Contains(searchString)));
}
private class Person
{
public string Firstname { get; set; } = string.Empty;
public string Lastname { get; set; } = string.Empty;
}
} If you remove [CascadingParameter]
public BlazoredModalInstance? ModalInstance { get; set; } Typeahead performs as expected. Edit: |
Looking at the changes from #217 the problem is rather obvious: protected override void OnParametersSet()
{
Initialize();
}
private void Initialize()
{
SearchText = "";
IsShowingSuggestions = false;
IsShowingMask = Value != null;
} The component [CascadingParameter]
public BlazoredModalInstance? ModalInstance { get; set; } is creating such a condition, where the parameter will bubble down and the I think the necessity of the Initialize call should be looked at and it needs to be prevented to fire repeatedly after the component has been initialized already. |
Thanks @SSchulze1989 for your insights. I'd like to mention that with Blazored.Modal v7.0.0 the Is there a way to identify why that happens? The call stack in the setter is kinda useless. Step out doesn't work. I tried setting various breakpoints in Blazored.Modal but that didn't get me closer to the answer. If preferred I can report this issue separately on Blazored.Modal. |
Good question. But in any case a component should be able to handle multiple calls to |
Opened a pr that should fix this issue without affecting the one where the selected value would not disappear after being set from outside. |
Great job! I figured out what is causing the frequent rerenders of BlazoredModal. I'm not sure if this needs to be fixed, but it does seem to generate some overhead. Perhaps it's possible to disable event propagation. What is your opinion? |
Also may be this make v7 much slower than 6.0.1. On previouse version modals closing instantly and on latest they have delay like 0.5 second. |
I think this is a separate issue and should definitely be tracked on the Blazored.Modam side. |
That is by design in v7.
Agreed, see Blazored/Modal#459 |
Please see attached screenshots. This behavior came after updating to version 4.7.0
`
<BlazoredTypeahead SearchMethod="SearchCDMS"
MinimumLength="1" Debounce="1000" placeholder="start typing to get results..."
@bind-Value="selectedItem">
The text was updated successfully, but these errors were encountered: