MudChipSet: use SelectionMode instead of MultiSelect and Mandatory#8722
MudChipSet: use SelectionMode instead of MultiSelect and Mandatory#8722henon merged 11 commits intoMudBlazor:devfrom
SelectionMode instead of MultiSelect and Mandatory#8722Conversation
|
The collection comparer can only be added to _selectedValues state once #8661 is merged. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #8722 +/- ##
==========================================
+ Coverage 89.82% 90.14% +0.31%
==========================================
Files 412 419 +7
Lines 11878 12181 +303
Branches 2364 2396 +32
==========================================
+ Hits 10670 10981 +311
+ Misses 681 664 -17
- Partials 527 536 +9 ☔ View full report in Codecov by Sentry. |
|
Added to v7.0.0 Migration Guide #8447 |
|
This one is done |
|
Tests failed, I wonder if it's related |
Yes. My implementation completely broke down, not sure why, but seeing how unstable it was I had to overhaul it again. I had to do it like in TreeView, that in single selection mode SelectedValues is ignored and in multi selection SelectedValue is ignored. |
Yea, it seems just adding comparer to SelectedValues break everything and the implementation requires |
|
Btw, not related question, but why such complicated GetHasCode? public int GetHashCode(IReadOnlyCollection<T> obj)
{
var hasher = new HashCode();
foreach (var item in obj)
{
if (item is not null)
{
hasher.Add(_comparer.GetHashCode(item));
}
}
return hasher.ToHashCode();
}Why does it require |
|
As I understand it hashing algorithms are not commutative. So if you hash [1, 2, 3] and [3,2,1] you'll get different results. |
|
And we don't know if the user supplies a hash set. IReadOnlyCollection can be anything, such as Array, List, etc |
Description
Followup to the ChipSet rework in #4342
Replaced the dual parameters
MultiSelectionandMandatorywithSelectionModewhich was originally introduced forMudToggleGroup.MudTreeViewnow also uses the newSelectionModeandMudListis also gonna use it when we implement multi-selection for it. This is an effort to unify selection features in the library.Note:
MudSelect,MudTableandMudDataGridand some others still useMultiSelect="true". We might also change them, but I doubt it is gonna be possible to do this in v7.Warning
MudChipSet: Replace the dual parameters
MultiSelectionandMandatorywithSelectionMode.MultiSelection="true"corresponds toSelectionMode.MultiSelection. For the default single-selection of the old chip set useSelectionMode.ToggleSelectionandMandatory="true"corresponds toSelectionMode.SingleSelection.Due to the unification of selection features over all components the default selection mode of MudChipSet has changed. Prior to v7 chips could be selected off by default. In v7 the default is
SelectionMode.SingleSelection(like for all other components that support parameterSelectionMode) which does not allow to de-select chips by clicking again. Set toSelectionMode.ToggleSelectionfor that. #8722trueSelectionMode.MultiSelectionfalsetrueSelectionMode.SingleSelectionfalsefalseSelectionMode.ToggleSelectionHow Has This Been Tested?
unit
Type of Changes
Checklist
dev).