Skip to content

MudDataGrid: Preserve initial sort definitions in single mode - #13749

Merged
danielchalmers merged 1 commit into
MudBlazor:devfrom
pttydou:fix/9021-sort-definitions-single-mode
Aug 31, 2026
Merged

danielchalmers merged 1 commit into
MudBlazor:devfrom
pttydou:fix/9021-sort-definitions-single-mode

Conversation

@pttydou

@pttydou pttydou commented Aug 30, 2026

Copy link
Copy Markdown

Fixes #9021.

MudDataGrid.SetParametersAsync compared the first incoming SortMode with the parameter's default value, so an initial Single mode was treated as a later mode transition and cleared caller-provided SortDefinitions. This change limits that clearing to post-first-render mode changes, preserving the existing behavior for real transitions.

Before/After:

01-before-B-A-C 02-after-A-B-C
  • Before: the initial Name sort is ignored and rows render in input order (B, A, C).
  • After: the same initial Name sort remains active and rows render as (A, B, C).

Tests:

  • dotnet test --project src/MudBlazor.UnitTests/MudBlazor.UnitTests.csproj --no-restore /p:SkipBunCompile=true -- --filter "FullyQualifiedName~DataGridSortDefinitionsPreservedOnInitialSingleModeRender" --output Normal --no-ansi --hangdump --hangdump-timeout 120s
  • dotnet test --project src/MudBlazor.UnitTests/MudBlazor.UnitTests.csproj --no-build --no-restore -- --filter "FullyQualifiedName~DataGridTests.DataGridSort" --output Normal --no-ansi --hangdump --hangdump-timeout 120s
  • dotnet test --project src/MudBlazor.UnitTests/MudBlazor.UnitTests.csproj --no-build --no-restore -- --filter "FullyQualifiedName~DataGridCustomSort|FullyQualifiedName~DataGridFilteredItemsCache" --output Normal --no-ansi --hangdump --hangdump-timeout 120s
  • dotnet format whitespace --no-restore --verify-no-changes --include MudBlazor/Components/DataGrid/MudDataGrid.razor.cs MudBlazor.UnitTests/Components/DataGridTests.cs

AI assistance was used through Codex with GPT-5.6 Sol for investigation, implementation, test drafting, and diff review. Human verification: before submission, the contributor confirmed that the attached screenshots from the local Viewer run show the same scenario changing from B, A, C to A, B, C.

Checklist:

  • I've read the contribution guidelines
  • My code follows the style of this project
  • I've added or updated relevant unit tests

@mudbot mudbot Bot added the bug Unexpected behavior or functionality not working as intended label Aug 30, 2026
@mudbot mudbot Bot changed the title MudDataGrid: Preserve initial sort definitions in single mode (#9021) MudDataGrid: Preserve initial sort definitions in single mode Aug 30, 2026

@versile2 versile2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@danielchalmers

Copy link
Copy Markdown
Member

Thanks!

@danielchalmers
danielchalmers merged commit eddf928 into MudBlazor:dev Aug 31, 2026
12 checks passed
This was referenced Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Unexpected behavior or functionality not working as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SortDefinitions parameter is ignored in MudDataGrid when SortMode is Single

3 participants