Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MudDataGrid: Filter for Nullable DateTime not working(#6521) #6607

Merged
merged 3 commits into from
Apr 8, 2023

Conversation

ScarletKuro
Copy link
Member

Description

Fixes #6521.

In the previous implementation, the code was checking for f.dataType == typeof(DateTime) in the razor file, which caused issues with filters not working correctly. The problem was that it did not account for nullable DateTime types.

To fix this, I added a new public property called FieldType to the FilterDefinition class, which checks for nullable types. The FieldType type already has all the necessary tests and works as expected. The updated code now uses f.FieldType.IsDateTime instead of f.dataType == typeof(DateTime). Additionally, I updated all the rest type checks to use FieldType instead.

I had to redo all the RenderFragments in MudDataGrid.razor due to compatibility issues with Visual Studio 2022. The file was not editable and caused a lot of problems, but everything is parsing smoothly now.

How Has This Been Tested?

Docs, reproduction snippet

Types 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)

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 Something does not work as intended/expected PR: needs review labels Apr 8, 2023
@codecov
Copy link

codecov bot commented Apr 8, 2023

Codecov Report

Patch coverage: 85.41% and project coverage change: -0.94 ⚠️

Comparison is base (61fbff8) 91.41% compared to head (455d1b0) 90.47%.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #6607      +/-   ##
==========================================
- Coverage   91.41%   90.47%   -0.94%     
==========================================
  Files         398      398              
  Lines       14955    13487    -1468     
==========================================
- Hits        13671    12203    -1468     
  Misses       1284     1284              
Impacted Files Coverage Δ
src/MudBlazor/Components/DataGrid/FieldType.cs 100.00% <ø> (ø)
...rc/MudBlazor/Components/DataGrid/MudDataGrid.razor 88.33% <84.44%> (-10.79%) ⬇️
src/MudBlazor/Components/DataGrid/Filter.cs 77.96% <100.00%> (-0.73%) ⬇️
.../MudBlazor/Components/DataGrid/FilterDefinition.cs 94.49% <100.00%> (+0.05%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Collaborator

@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.

I think there is a typo FiledType instead of FieldType

@ScarletKuro
Copy link
Member Author

ScarletKuro commented Apr 8, 2023

You are right. Ty for noticing, this would be a disaster 😭.

@ScarletKuro ScarletKuro requested a review from henon April 8, 2023 15:28
@henon
Copy link
Collaborator

henon commented Apr 8, 2023

I am sure this is gonna create a lot of conflicts though :(

@ScarletKuro
Copy link
Member Author

ScarletKuro commented Apr 8, 2023

The RenderFragments change - yes :( But it was really bad before.
From what I see it will affect only this PR #6212 Also this bug was before the 6.2.0 it's not clear if it's still exist.
all others that modified the MudDataGrid.razor are already affected by the PropertyExpression change.

@henon henon merged commit 037ea61 into MudBlazor:dev Apr 8, 2023
2 of 3 checks passed
@henon
Copy link
Collaborator

henon commented Apr 8, 2023

Thanks @ScarletKuro !

@tjscience FYI

@ScarletKuro ScarletKuro deleted the fix_6521 branch April 8, 2023 16:35
ilovepilav pushed a commit to ilovepilav/MudBlazor that referenced this pull request Nov 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something does not work as intended/expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MudDataGrid filter for "DateTime?" not working
2 participants