Skip to content

Fix nested list selection state in MudSelectExtended - #657

Open
pigwing wants to merge 1 commit into
CodeBeamOrg:devfrom
pigwing:codex/fix-nested-multiselect-selection
Open

pigwing wants to merge 1 commit into
CodeBeamOrg:devfrom
pigwing:codex/fix-nested-multiselect-selection

Conversation

@pigwing

@pigwing pigwing commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Nested items in MudSelectExtended can get out of sync with the bound selection in 9.3.0 and the current dev branch. Clicking an item's row adds its value, but its checkbox/aria-selected can remain false; clicking the same row again then fails to deselect it.

Reproduction

<MudSelectExtended T="string" MultiSelection="true" @bind-SelectedValues="_selectedValues">
    <MudSelectItemGroupExtended T="string" Text="Group" Nested="true" InitiallyExpanded="true">
        <MudSelectItemExtended T="string" Value="@("first")" Text="First" />
        <MudSelectItemExtended T="string" Value="@("second")" Text="Second" />
    </MudSelectItemGroupExtended>
</MudSelectExtended>

@code {
    private IEnumerable<string> _selectedValues = ["first"];
}

Open the select and click the Second row, outside its checkbox. Both values should be selected and visibly checked. Click that row again: only first should remain selected. On the affected version, the bound values and item state disagree, and the second row click does not remove second.

Fix

Nested MudListExtended instances do not maintain independent selected-value fields: their setters return when ParentList is present, and item selection is handled by the parent. Their getters nevertheless read the local fields, so nested items can initialize or synchronize from stale/empty state.

Delegate the SelectedValue and SelectedValues getters to ParentList, recursively reaching the root selection. This also propagates a cleared/null single selection correctly. The production change is two getter expressions; no public parameters or selection semantics are changed.

Add six regression cases covering expanded/collapsed groups, parent-driven updates, selection across groups, deselection, repeated row clicks, and nested single-selection changes/clearing.

Validation

  • Ran the complete unit-test project with the new tests against unchanged dev: 334 passed, 5 failed. All five failures are in the new regression cases.
  • With the fix: 339 passed, 0 failed. The same two explicit stress tests were not executed in either run.
  • Built the library for net8.0, net9.0, and net10.0 successfully (existing warnings, no errors).
  • Browser comparison using MudBlazor 9.12.0: reproduced the row/checkbox mismatch with the 9.3.0 package, then verified row and checkbox selection/deselection with the fix, with one selection-change callback per action.

Commands: dotnet test tests/CodeBeam.MudBlazor.Extensions.UnitTests/CodeBeam.MudBlazor.Extensions.UnitTests.csproj -p:CI=true and dotnet build src/CodeBeam.MudBlazor.Extensions/CodeBeam.MudBlazor.Extensions.csproj -p:CI=true.

@codecov

codecov Bot commented Nov 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.40%. Comparing base (7b71925) to head (89c7d11).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #657      +/-   ##
==========================================
+ Coverage   67.32%   67.40%   +0.08%     
==========================================
  Files         117      117              
  Lines        8550     8550              
  Branches     1510     1512       +2     
==========================================
+ Hits         5756     5763       +7     
+ Misses       2253     2247       -6     
+ Partials      541      540       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant