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

[DataGridPro] Fetch new rows only once when multiple models are changed in one cycle #16101

Merged
merged 23 commits into from
Jan 29, 2025

Conversation

arminmeh
Copy link
Contributor

@arminmeh arminmeh commented Jan 8, 2025

Extracted from the work in #15378
It is also needed in #15548

This way, it will be easier to cherry pick it to v7

@arminmeh arminmeh added component: data grid This is the name of the generic UI component, not the React module! plan: Pro Impact at least one Pro user enhancement This is not a bug, nor a new feature needs cherry-pick The PR should be cherry-picked to master after merge v7.x feature: Server integration Better integration with backends, e.g. data source labels Jan 8, 2025
@mui-bot
Copy link

mui-bot commented Jan 8, 2025

Deploy preview: https://deploy-preview-16101--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against 65195eb

@arminmeh arminmeh marked this pull request as draft January 8, 2025 16:30
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 9, 2025
Copy link

github-actions bot commented Jan 9, 2025

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@arminmeh arminmeh force-pushed the debouce-fetch-rows branch from 679f628 to d5c8643 Compare January 9, 2025 12:40
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 9, 2025
@arminmeh arminmeh force-pushed the debouce-fetch-rows branch 2 times, most recently from 695e46e to 25fd944 Compare January 10, 2025 12:54
@arminmeh arminmeh marked this pull request as ready for review January 10, 2025 13:27
@arminmeh arminmeh requested a review from a team January 10, 2025 13:27
@arminmeh
Copy link
Contributor Author

It looks like that setProps helper does not play nicely if you have debounce.
I could see in the console that the new fetch call is being made, but the callCount would not update in the spy. Switching to apiRef helped.

@cherniavskii
Copy link
Member

It looks like that setProps helper does not play nicely if you have debounce.

That's super weird. This might be a symptom of an issue on our side. I'll take a look at it to better understand what's going on there.

Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 24, 2025
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 28, 2025
Copy link
Member

@MBilalShafi MBilalShafi left a comment

Choose a reason for hiding this comment

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

Thanks for the additional updates around the test cases.

@arminmeh
Copy link
Contributor Author

arminmeh commented Jan 29, 2025

@cherniavskii I had to update the setup once more.
the one that you have pushed doesn't work when the settings of the mock server change (like to throw an error)
mock server was always just returning empty response, because the data was not there after memo

as a workaround I have created an empty spy and I call both spy and the mock server with the same params one after the other

also, spy is reset on every data source change which updates correctly once mock server config is changed but is kept after re-rendering

in addition to this I have changed the way custom cache is used. one test with the cache was flaky erroring on the check of the cache size. Now, each test has it's own instance of the test cache

@arminmeh arminmeh merged commit 4f68960 into mui:master Jan 29, 2025
18 checks passed
Copy link

Cherry-pick PRs will be created targeting branches: v7.x

@arminmeh arminmeh deleted the debouce-fetch-rows branch January 29, 2025 11:40
lauri865 pushed a commit to lauri865/mui-x that referenced this pull request Jan 29, 2025
arminmeh added a commit to arminmeh/mui-x that referenced this pull request Jan 29, 2025
@@ -324,6 +322,8 @@ export const useGridDataSourceBase = <Api extends GridPrivateApiPro>(
[apiRef],
);

const debouncedFetchRows = React.useMemo(() => debounce(fetchRows, 0), [fetchRows]);
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if using a microtask callback wouldn't have been better than a timeout (aka task). It would keep the overall update to within the same event loop cycle.

A-s-h-o-k pushed a commit to A-s-h-o-k/mui-x that referenced this pull request Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature feature: Server integration Better integration with backends, e.g. data source needs cherry-pick The PR should be cherry-picked to master after merge plan: Pro Impact at least one Pro user v7.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants