2

Adding

@* This returns the description of the selected item based on its id *@

ToStringFunc="id => dataLoader.GetDescriptionFromList(brandModelsList, id)"

causes the MudSelect component to flicker when clicking on it to open or close. I guess it rerenders ? Is there any way I could get around that? Also, i use virtualization as shown here because the items of the list are 1000+ This is the code:

    <MudText Typo="Typo.subtitle1" GutterBottom="false">Brand Model</MudText>
    <MudSelect T="int?" @bind-Value="customForm.SelectedBrandModelId"
               Variant="Variant.Outlined"
               Margin="Margin.Dense"
               Dense="true"
               PlaceHolder="Select"
               ToStringFunc="id => dataLoader.GetDescriptionFromList(brandModelsList, id)">
        @if (!brandModelsList.Any())
        {
            <MudSelectItem T="int?" Value="null" Disabled="true">not found</MudSelectItem>
        }
        else
        {
            <Virtualize Items="brandModelsList" Context="brandModel" ItemSize="36">
                <MudSelectItem T="int?" Value="@brandModel.ID" @key="brandModel.ID">@brandModel.Description</MudSelectItem>
            </Virtualize>
        }
    </MudSelect>
</div>
<ValidationMessage For="@(() => customForm.SelectedBrandModelId)" class="validation-error-message" />

I want want to reduce flicker when opening the component

2
  • Can you try and create a reproducible snippet here and add that to your question. Commented Jul 29 at 20:11
  • @RBee I’ve posted the answer below. Thanks for your reply Commented Jul 29 at 20:56

1 Answer 1

0

Hello guys I’ve found the bug. From my understanding Blazor needs the key attribute to correctly track changes in the UI if binding is not applied and for some reason in my master branch on GitHub this part of the code was missing:

@key="brandModel.ID"
Sign up to request clarification or add additional context in comments.

1 Comment

search Blazor "data-permanent"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.