Skip to content

MudDataGrid: Refresh grouping after InvokeServerLoadFunc, ExpandAllGroups, CollapseAllGroups#9150

Merged
ScarletKuro merged 7 commits intoMudBlazor:devfrom
MihFig:fix/datagridgrouping
Jun 10, 2024
Merged

MudDataGrid: Refresh grouping after InvokeServerLoadFunc, ExpandAllGroups, CollapseAllGroups#9150
ScarletKuro merged 7 commits intoMudBlazor:devfrom
MihFig:fix/datagridgrouping

Conversation

@MihFig
Copy link
Contributor

@MihFig MihFig commented Jun 9, 2024

Description

Fixes #9149

How Has This Been Tested?

Only manually inside my own project used MudBlazor

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 Jun 9, 2024
@codecov
Copy link

codecov bot commented Jun 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.67%. Comparing base (28bc599) to head (7967635).
Report is 265 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #9150      +/-   ##
==========================================
+ Coverage   89.82%   90.67%   +0.84%     
==========================================
  Files         412      400      -12     
  Lines       11878    12510     +632     
  Branches     2364     2436      +72     
==========================================
+ Hits        10670    11343     +673     
+ Misses        681      624      -57     
- Partials      527      543      +16     

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

@ScarletKuro
Copy link
Member

Hi.
Thanks for PR.
Please, add a bUnit test for this case.

MihFig added 2 commits June 9, 2024 18:27
Add GroupItems calls to ExpandAllGroups(), CollapseAllGroups() and make them async
@ScarletKuro
Copy link
Member

Thanks for the test.

Now I'm concerned about the async void you just added. We don't allow that anymore.

Is the InvokeAsync required? If yes, then we should consider breaking the API and make CollapseAllGroups / ExpandAllGroups return a Task and add the Async suffix.

@MihFig
Copy link
Contributor Author

MihFig commented Jun 9, 2024

Is the InvokeAsync required?

In my opinion yes - GroupItems() calls StateHasChanged() and need to refresh view after click.

If yes, then we should consider breaking the API and make CollapseAllGroups / ExpandAllGroups return a Task and add the Async suffix.

I am doing it right now.

During test creation I noticed buttons ExpandAll/CollapseAll not working too in this scenario - and they do not working in pasted in issue snippet either - thats why I changed it

ExpandAllGroups, CollapseAllGroups => ExpandAllGroupsAsync, CollapseAllGroupsAsync
@ScarletKuro ScarletKuro added the breaking change This change will require consumer code updates label Jun 9, 2024
@ScarletKuro ScarletKuro requested review from henon and tjscience June 9, 2024 18:23
@henon henon changed the title Add GroupItems method after InvokeServerLoadFunc MudDataGric: Refresh grouping after InvokeServerLoadFunc Jun 10, 2024
@henon
Copy link
Contributor

henon commented Jun 10, 2024

Is the InvokeAsync required?

In my opinion yes - GroupItems() calls StateHasChanged() and need to refresh view after click.

In your opinion? I'd rather go with hard facts. Did you test without InvokeAsync and it didn't work?

If I'm not mistaken InvokeAsync is only needed if you are currently not on the render thread, i.e. on a background worker or timer thread or if you are on the render thread but you need to trigger another render for some reason.

@ScarletKuro
Copy link
Member

ScarletKuro commented Jun 10, 2024

If I'm not mistaken InvokeAsync is only needed if you are currently not on the render thread.

That's correct. It should be be always on the UI thread when it comes from OnClick or any other UI interactivity.
I guess it didn't work in test:

await comp.Instance.CollapseAllGroupsAsync();

but in that case the

await comp.InvokeAsync(() => comp.Instance.CollapseAllGroupsAsync());

should be used.

@MihFig MihFig changed the title MudDataGric: Refresh grouping after InvokeServerLoadFunc MudDataGrid: Refresh grouping after InvokeServerLoadFunc Jun 10, 2024
@MihFig
Copy link
Contributor Author

MihFig commented Jun 10, 2024

You're right @henon @ScarletKuro - I rolled back the incorrect changes

@henon henon removed breaking change This change will require consumer code updates PR: needs review labels Jun 10, 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.

LGTM, can be merged

@MihFig MihFig changed the title MudDataGrid: Refresh grouping after InvokeServerLoadFunc MudDataGrid: Refresh grouping after InvokeServerLoadFunc, ExpandAllGroups, CollapseAllGroups Jun 10, 2024
@ScarletKuro ScarletKuro merged commit 912aed2 into MudBlazor:dev Jun 10, 2024
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 not refreshing grouping with ServerData

3 participants