-
-
Notifications
You must be signed in to change notification settings - Fork 533
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
Select component doesn't recognize changes by code #1100
Comments
Is there a way to get the component with |
Try calling |
Already tried. But it didn’t help. It seems that the select component holds a different reference of |
I think the problem is because you always get the selected items from DOM with javascript. |
I didn't check it yet, but I will put it on the list for 0.9.2 release and try to fix it for one of the next previews. |
It seems that the error is somewhere else when the select component is re-rendered. |
I'm using this code to test the select <Select Multiple="true" TValue="int" @bind-SelectedValues="@selectedTags" MaxVisibleItems="10">
@foreach ( var item in tags ?? Enumerable.Empty<int>() )
{
var value = item;
<SelectItem @key="@value" TValue="int" Value="@value">@value</SelectItem>
}
</Select>
<p>
Selected:
@foreach ( var item in selectedTags ?? Enumerable.Empty<int>() )
{
<span>@item</span>
}
</p>
<Button Color="Color.Primary" Clicked="@ShowEditForm">TEST</Button>
@code {
IReadOnlyList<int> tags = new int[] { 1, 2, 3, 4, 5, 6, 7, 8 };
IReadOnlyList<int> selectedTags = new int[] { 1, 2, 3 };
private Task ShowEditForm()
{
selectedTags = new int[] { 2, 4, 6 }.ToList().AsReadOnly();
return Task.CompletedTask;
}
} The select works great, It will get and set the values as expected. BUT the weird bug happen as soon as I CLICK on any options. Everything breaks. Select component will not refresh after I click on the TEST button, and when I inspect elements in devtools everything seems fine. And I need to clear head before I continue with this one :) |
Got also some headache 😉 |
More I'm thinking this is not going to be fixed that soon: |
Going to pause this ticket. I've being searching for a solution entire day, and whatever I try nothing works. So for now I'm going to proceed with other tickets and in the meantime I will try to research some more options. Maybe all I need is a different perspective. I hope this OK with you @martinscholz83 |
Fine for me. As a workaround we show in a textfield what tags are currently saved in database. Thx for investigating on this issue! |
Oh, one more question I have if it’s ok. I also use tab elements. And on every tab change the whole page is reloading. Is that wanted? Is it the concept of blazor to reload the complete razor page when something is triggered an onchange event? |
@stsrki, seems that this is already fixed. Can you confirm? |
Nop, still not working for me. |
For me when changing |
I tried the example #1100 (comment)
you will see it doesn't update |
Bildschirmaufnahme.2021-03-01.um.15.22.58.mov |
Now I'm really confused... What version do you use? 0.9.2 or 0.9.3 RC? |
And browser? |
Safari Version 14.0.3 (16610.4.3.1.4) |
The only one I can't test with :) So far I tried Chrome, Firefox and Edge. Same problem. |
Oh, I see. In Edge or Chrome it doesn't work |
I switched while testing from Chrome to Safari |
But what is then the main issue. The underlying javascript engine? |
That is the only reason that comes to my mind. |
Safari does not always go with the standards so in this case, it works, unlike with other browsers that are probably following some (to me) unknown rule. |
Ok. But for me the question is, who will fix this? Not specially for your |
I was trying something new this afternoon and I had some good results. It's a little ugly still but I think I will be able to make it work 🤞 |
Describe the bug
For example you have an edit form with a multiple select component. When select items
SelectedItems
contains the selected values. But when changingSelectedItems
by code, the Select component doesn't recognize this change.To Reproduce
Steps to reproduce the behavior:
Expected behavior
Select component should update itself when
SelectedItems
is changed by code.The text was updated successfully, but these errors were encountered: