Blazorise icon indicating copy to clipboard operation
Blazorise copied to clipboard

Late-bound SelectList data source causes SelectList to be very narrow

Open GeertvanHorrik opened this issue 3 years ago • 3 comments

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:

  1. Add this to a page:
<SelectList TItem="MyModel"
            TValue="MyModel"
            Data="@MyItems"
            TextField="@((item)=>item.DisplayName)"
            ValueField="@((item)=>item)"
            @bind-SelectedValue="@SelectedItem" />
  1. Start with null value or empty array of @MyItems
  2. 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

image

Additional context

Using Ant Design.

GeertvanHorrik avatar Jun 29 '22 17:06 GeertvanHorrik

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.

David-Moreira avatar Jun 30 '22 23:06 David-Moreira

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.

GeertvanHorrik avatar Jul 01 '22 07:07 GeertvanHorrik

For others having the same issue, a workaround I use for now is this:

    <SelectList Style="width: 200px"
                       ... />

GeertvanHorrik avatar Jul 14 '22 07:07 GeertvanHorrik