ant-design-blazor icon indicating copy to clipboard operation
ant-design-blazor copied to clipboard

Can't get Select component to refresh

Open michaelcsikos opened this issue 2 years ago • 5 comments

Inside a Drawer I have several Select components which are bound to a ViewModel object. When the values are changed in the bound ViewModel the Select components are not refreshing to show the current value. If I output the value on the page as text, the values are correct. I have tried calling StateHasChanged but it's not helping. What can I do to force the Select components to refresh?

michaelcsikos avatar Jan 16 '24 08:01 michaelcsikos

To be clear, the items in the DataSource for the Select are not being changed in the code, it's just the @bind-Value which is not refreshing.

michaelcsikos avatar Jan 16 '24 09:01 michaelcsikos

Thanks for contacting us @michaelcsikos . It's it only have issue in Drawer? How about put the select components on the page?

ElderJames avatar Jan 17 '24 15:01 ElderJames

Hi @ElderJames, if I place a second instance of the same components on the page bound to the same ViewModel it refreshes correctly, so it appears to be only a problem with the drawer.

If I select a different value in the drawer Select, the second instance on the page immediately refreshes to show the correct value. But editing the page's Select does not refresh in the drawer.

michaelcsikos avatar Jan 17 '24 23:01 michaelcsikos

@michaelcsikos Hi, could you provide a demo? I haven't reproduced it on my local (may be different from your usage)

https://github.com/ant-design-blazor/ant-design-blazor/assets/24973084/4ca56ffd-4345-4a86-95d1-0f1863d0ee09

zxyao145 avatar Jan 20 '24 10:01 zxyao145

@michaelcsikos Is this select that is not working contained in a form with ValidateOnChange = true?

If so the above pull request will fix. Otherwise this is a separate bug but the pull request is still valid.

My first pull request so go easy on me :).

edwardbarford avatar Feb 26 '24 20:02 edwardbarford