Skip to content

MudDataGrid: Allow grouping by null values#10213

Merged
ScarletKuro merged 9 commits intoMudBlazor:devfrom
ScarletKuro:nullobject
Nov 9, 2024
Merged

MudDataGrid: Allow grouping by null values#10213
ScarletKuro merged 9 commits intoMudBlazor:devfrom
ScarletKuro:nullobject

Conversation

@ScarletKuro
Copy link
Member

@ScarletKuro ScarletKuro commented Nov 8, 2024

Description

Fixes: #9259
Also fixes what I mentioned here: #9937 (comment)

How Has This Been Tested?

Visually on datagrid + bUnit and NUnit tests.

Type of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (fix or improvement to the website or code docs)

Checklist

  • The PR is submitted to the correct branch (dev).
  • My code follows the code style of this project.
  • I've added relevant tests.

@github-actions github-actions bot added bug Unexpected behavior or functionality not working as intended PR: needs review labels Nov 8, 2024
@codecov
Copy link

codecov bot commented Nov 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.23%. Comparing base (12c5dec) to head (8ff3433).
Report is 3 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev   #10213      +/-   ##
==========================================
+ Coverage   91.21%   91.23%   +0.02%     
==========================================
  Files         411      412       +1     
  Lines       12506    12536      +30     
  Branches     2439     2446       +7     
==========================================
+ Hits        11407    11437      +30     
  Misses        555      555              
  Partials      544      544              

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

@ScarletKuro
Copy link
Member Author

@henon, if you approve the NullObject, I will write tests for both the NullObject and the DataGrid grouping. Otherwise, I don’t want to waste my energy.

There is no easier way, as dictionaries don’t support null keys. I do think the way the dictionary are used in these two cases is a code smell, but having this wrapper is the easiest solution compared to introducing our own nullable dictionary or using something other than a dictionary and ending up having to rewrite everything. This NullObject is very lightweight and shouldn’t impact performance or memory—there’s no boxing/unboxing in the equality comparison link.

@ScarletKuro ScarletKuro requested a review from henon November 8, 2024 16:57
@henon
Copy link
Contributor

henon commented Nov 8, 2024

Ok, this is a good solution. Just the name is not good. Currently it suggests a Null Object which is a design pattern. Class doesn't represent a classical null object because it does not represent just a null value, it represents a value/object that might also be null. So it is a nullable wrapper. Maybe we should call it that (NullableWrapper or NullableObject)?

@ScarletKuro ScarletKuro self-assigned this Nov 8, 2024
@ScarletKuro
Copy link
Member Author

ScarletKuro commented Nov 9, 2024

This feature (bug fix) is ready. I think it turned out to be a very decent change.

upd: Actually tmr I want to do few adjustments and test with structs generics just in case done

@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 9, 2024

@henon henon changed the title MudDataGrid: Grouping by a null value MudDataGrid: Allow grouping by a null value Nov 9, 2024
@henon henon changed the title MudDataGrid: Allow grouping by a null value MudDataGrid: Allow grouping by null values Nov 9, 2024
Copy link
Contributor

@henon henon left a comment

Choose a reason for hiding this comment

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

Great. Feel free to merge

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.

MudDataGrid Grouping by a null value

2 participants