CodeBeam.MudBlazor.Extensions icon indicating copy to clipboard operation
CodeBeam.MudBlazor.Extensions copied to clipboard

[Bug] MudListExtended SelectAllState is not correctly set with initial selection

Open Geccoka opened this issue 2 years ago • 3 comments
trafficstars

Using the MudListExtended component if the SelectAll option is enabled, and set the ItemCollection and SelectedValues to different lists but with the same elements, the SelectAll checkbox is not correctly set initially, it remains blank.

Can be reproduced on the test page:

https://codebeam-mudextensions.pages.dev/mudlistextended

In the The Variants section if you click the MultiSelection and Select All, the Select All checkbox should be in intermediate state.

The issue can be caused by this condition in OnAfterRender:

https://github.com/CodeBeamOrg/CodeBeam.MudBlazor.Extensions/blob/7b582edfc55a3f882c12e9f029edc725a7fab06d/CodeBeam.MudBlazor.Extensions/Components/ListExtended/MudListExtended.razor.cs#L725C39-L725C39

Geccoka avatar Oct 05 '23 07:10 Geccoka

You mean setting values individually doesn't set select all checkbox automatically, right?

mckaragoz avatar Oct 05 '23 10:10 mckaragoz

Yes, basicly if you set the SelectedValues programatically to some non empty collection, after the List component loading, the state of the select all checkbox should be set accordingly.

kép

This image is from the demo site, after page load. Here, the Sparkling Water is set by default in code. The problem is that the select all checkbox is not in intermediate state but in false state.

Current workaround for me is easy because i already have a custom inherited class, so i just call UpdateSelectAllState after render in my code:

    protected override Task OnAfterRenderAsync(bool firstRender)
    {
        // Workaround for https://github.com/CodeBeamOrg/CodeBeam.MudBlazor.Extensions/issues/288
        if (firstRender)
            UpdateSelectAllState();

        return base.OnAfterRenderAsync(firstRender);
    }

Geccoka avatar Oct 05 '23 10:10 Geccoka

I think the bug is not only about on first render, so we should add a mechanism that updates select all state on programmatically change, at least we should add a manual method that users can freely call to update.

mckaragoz avatar Oct 05 '23 10:10 mckaragoz