-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[data grid] Asynchronous configuration of specific props seem to trigger onSortModelChange callback #8018
Comments
The DataGrid has a built-in logic that filters out from mui-x/packages/grid/x-data-grid/src/hooks/features/sorting/useGridSorting.ts Lines 326 to 332 in 89c3137
The You could solve this bug by only rendering the DataGrid after the columns have been loaded. Is it possible? |
@m4theushw That's something we actually considered doing. It looked a bit less nice than just leaving the grid in a loading state but it's possible. For me the biggest "issue" is that it feels a bit random depending on the order the props are received. E.g. if we delay creating the |
I've thought about it and maybe a better question is, what is the expected behavior for the |
Ping @MBilalShafi, can you take this one? |
Sure @romgrk, I'll have a look. |
Order ID 💳
2208761
Duplicates
Latest version
The problem in depth 🔍
So we're trying to integrate the
DataGridPro
with our backend and we're noticing some strange behavior. It might be intended I'm not sure. We fetch some settings from our backend and then fetch the data based on those settings. The settings only have some config like the width of a column, if a column is pinned, sorting things like that. The data actually contains which columns are all available.So what we're trying to do is the following:
sortModel
,pinnedColumns
props.columns
prop.So what we're experiencing is that because we're first setting up the
sortModel
andpinnedColumns
that it's somehow triggering theonSortModelChange
callback with an empty array. If we change the order slightly sopinnedColumns
updates beforesortModel
or aftercolumns
it doesn't trigger the callback.In the following sandbox you can see the issue:
https://codesandbox.io/s/confident-rumple-ft7s9t?file=/demo.tsx
If you play around with the timeout in the
useEffect
that sets the pinned columns you should be able to see the issue.Maybe it isn't intended to be implemented like this or it might be a bug I'm not sure. We were at least scratching our heads here as to why the sorting was disappearing every time 😅.
Your environment 🌎
No response
The text was updated successfully, but these errors were encountered: