CodeBeamOrg / CodeBeam.MudBlazor.Extensions

Useful third party extension components for MudBlazor, from the contributors.
https://mudextensions.codebeam.org/
MIT License
367 stars 62 forks source link

Add missing item.SetSelected call for multi select when pre-selection is provided #240

Closed radderz closed 11 months ago

radderz commented 11 months ago

Add missing item.SetSelected call for multi select when pre-selection is provided.

The issue this resolves is when MultiSelection is on, and SelectedValues is provided by the outside component, the selection is only set for the last item in the selected values instead of all of the values. As soon as you scroll a list it refreshes the selection and shows the selected items correctly. But on first render it's wrong.

radderz commented 11 months ago

I think this might also fix #109 .

The issue was when the list is rendered, only the last selected item was being set as selected in the Register method for the list items. So it wasn't starting off with the right selected state on first render.

radderz commented 11 months ago

I added an additional fix to the ListExtended. Select All was only selecting elements that were on the DOM, I made it so that if it is bound to an item collection (which is required for virtualising) it will select the values based on the item collection values not based on the items currently rendered on the DOM. I also handle the same logic in the part where it determines if the select all should be checked or partial or unchecked after user clicks.

This also fixes the behaviour when adding in a filter in the search, it removes items from the DOM, which unregisters them. So selecting all only includes the searched items. This will now select all ignoring the filter which makes sense as otherwise if you remove the filter after selecting all, it'll still show it as being select all even though some items are not checked.

mckaragoz commented 11 months ago

Thanks, this one is really good catch 🥇