Skip to content

MudSelectExtension #566

Open
Open

Description

@Magic73

Hi,
I have a strange issue with the Chip visualization.
I see the Chips only when the dropdown is open:

Image

then, they disappears when the drop is closed

Image

(in the same page, if I copy/paste the example from your doc page, the one with complex items.. it works as expected)

I do not understand why I have this issue.

this is the razor code:

    <MudSelectExtended Label="@localizer[Strings.Tournament]"
                         ValuePresenter="ValuePresenter.Chip"
                         ChipCloseable="true"
                         ChipSize="Size.Small"
                         ChipVariant="Variant.Text"
                         NoWrap="false"
                         AnchorOrigin="Origin.BottomCenter"
                         T="int"
                         MultiSelection="true"
                         @bind-SelectedValues="@TournamentIds"
                         @bind-SelectedValues:after="OnTournamentChanged">

          @foreach (var tournament in Tournaments)
          {
              <MudSelectItemExtended T="int" Value="@tournament.TournamentId" Text="@tournament.Name" />
          }
      </MudSelectExtended>

where

List<TournamentModel> Tournaments = new List<TournamentModel>();
 IEnumerable<int> TournamentIds = new HashSet<int>();

if I switch from Chip to Text, it works as expected.

Activity

  1. mckaragoz commented on Nov 10, 2025

    @mckaragoz
    Contributor

    Need more info, could you reproduce an example with minimal code?

  2. cruisi commented on Dec 23, 2025

    @cruisi

    I found the issue.

    the MudInputCssHelperExtended.GetClassname that doesn't set mud-shrink class.
    () => HasNativeHtmlPlaceholder() || ShrinkLabel == true || !string.IsNullOrEmpty(Text) || !string.IsNullOrWhiteSpace(Placeholder) || !string.IsNullOrEmpty(Converter.Set(Value)));

    all of these checks are false, but the last one should be true..

    this is my component setup:

            <MudSelectExtended T="int"
                                 ItemCollection="Tournaments.Select(t => t.TournamentId).ToList()"
                                 Label="@localizer[Strings.Tournaments]"
                                 ToStringFunc="@(v => Tournaments.FirstOrDefault(t=>t.TournamentId == v)?.Name ?? "")"
                                 Variant="Variant.Text"
                                 ValuePresenter="ValuePresenter.Chip"
                                 Disabled="@(Tournaments.Count() == 0)"
                                 ReadOnly="@ReadOnly"
                                 ChipCloseable="true"
                                 ChipSize="Size.Small"
                                 ChipVariant="Variant.Text"
                                 MultiSelection="true"
                                 @bind-SelectedValues="@TournamentIds"
                                 @bind-SelectedValues:after="() => OnTournamentChanged()" />
    

    I fixed adding
    ShrinkLabel="@(TournamentIds.Any())"

  3. cruisi commented on Dec 23, 2025

    @cruisi

    the same issue happens with groups, but this time the problem is the use of groups. Not using the ItemCollection, but the group defined as content, means that the Items collection fills up when the popup is open (the Add function is called) but then empties when the popup is closed (the Dispose function is called, followed by the subsequent Remove function).

    Itemscollection is empty, Items is empty, and nothing is displayed.

    this is my setup:

       <MudSelectExtended Label="@localizer[Strings.Events]"
                            ValuePresenter="ValuePresenter.Chip"
                            ReadOnly="@ReadOnly"
                            Disabled="@(Events.Count() == 0)"
                            ShrinkLabel="@(EventIds.Any())"
                            Clearable="true"
                            ChipCloseable="true"
                            ChipSize="Size.Small"
                            ChipVariant="Variant.Text"
                            NoWrap="false"
                            AnchorOrigin="Origin.BottomCenter"
                            T="int"
                            MultiSelection="true"
                            @bind-SelectedValues="@EventIds"
                            @bind-SelectedValues:after="() => OnItemsChanged()">
           @foreach (var group in Events.OrderBy(e => e.EventDate).GroupBy(e => e.EventDate.Date))
           {
               <MudSelectItemGroupExtended Text="@(group.Key.ToString("d"))" T="int">
                   @foreach (var evt in group)
                   {
                       <MudSelectItemExtended Value="@evt.EventId"
                                                T="int"
                                                Text="@evt.EventName" />
                   }
               </MudSelectItemGroupExtended>
           }
       </MudSelectExtended>
    
  4. mckaragoz commented on Dec 23, 2025

    @mckaragoz
    Contributor

    I found the issue.

    MudInputCssHelperExtended.GetClassname that doesn't set mud-shrink class.

    If it's only about mud-shrink it will be easy. These code looks wrong, it should check HasValue result instead of converter result of value. Because each component implement it's own HasValue algorithm, and your examples has multiselectable.

  5. cruisi commented on Dec 24, 2025

    @cruisi

    in your example works, beacuse you do the binding to Value (but it should be unecessary for a multiselection, since there's already the Values binding).

            <MudSelectExtended MultiSelectionTextFunc="@(_radioGroup?.Value == 1 ? new Func<List<int?>, string?>(GetMultiSelectionText) : null)" 
    MultiSelection="true" 
    ValuePresenter="_valuePresenter" T="int?" 
    
    @bind-Value="intValue"
    @bind-SelectedValues="intValues"
    
     Label="Complex Type" 
    AnchorOrigin="Origin.BottomCenter"
    ChipCloseable="_chipCloseable"
     ChipSize="_chipSize" 
    ChipVariant="_chipVariant"
     NoWrap="_nowrap">
                @foreach (var item in complexes)
                {
                    <MudSelectItemExtended T="int?" Value="@item.Value" Text="@item.Text" />
                }
            </MudSelectExtended>
    

    I'm trying to find why the selected chips are not showing...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions