Blazorise
Blazorise copied to clipboard
Late-bound SelectList data source causes SelectList to be very narrow
Describe the bug
When I am binding the data source late-bound (e.g. during initialization) using AntDesign, it always shows up narrow.
To Reproduce
Steps to reproduce the behavior:
- Add this to a page:
<SelectList TItem="MyModel"
TValue="MyModel"
Data="@MyItems"
TextField="@((item)=>item.DisplayName)"
ValueField="@((item)=>item)"
@bind-SelectedValue="@SelectedItem" />
- Start with null value or empty array of
@MyItems - Lazy load the values
The SelectList will populate with the correct values but display incorrectly.
Expected behavior
A normal SelectList behavior where it's wide enough to show the items.
Screenshots

Additional context
Using Ant Design.
I'm guessing as a temporary workaround
@if(MyItems is not null) might work just fine for you, right? Only happens when component is already rendered and data changes with Ant Design?
Can you try the workaround, It should still, ideally, work as you've described.
I was binding to collection count for visibility since I use explicit nullable in the project. Will mark it as nullable and set it to null when count == 0 as a workaround for now.
For others having the same issue, a workaround I use for now is this:
<SelectList Style="width: 200px"
... />