-
-
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] Improve "Save and restore the state from external storage" demo #11576
Comments
For inspiration: In Toolpad we wrote a hook that handles initializing state from localstorage on the first render correctly (i.e. doesn't need an effect to run). It also syncs this state across tabs. |
@Janpot What do you think about moving the This could also be an initiative under the MUI X product line - cc @joserodolfofreitas @oliviertassinari @mui/x |
Yes, I'll clean it up a bit and move to |
To be noted that @mui/utils is a "private" npm package. Only MUI System and Base UI are supposed to import from it. This package exists so that MUI System doesn't have a dependency on Base UI (would be weird, and isolate download npm stats) but still able to use some of its logic to create components. |
We did not close the discussion about MUI X using it |
Just to note that this example is promoting Other places where
IMO, the |
What would prevent us from following semver? Couldn't we make this public and follow best practices as well? |
Nothing prevents us, it just adds overhead. It needs to be properly maintained, backwards compatibility needs to be guaranteed more tightly, and it needs to be documented. edit: To be clear, I interpreted the question as "what prevents us from treating |
I don't think making it public is a good idea. The code in there is internal code that we need to share across our packages/repos, not code we want the public to consume. I think we should either clearly mark it as a private package or create a new one with a name like
I don't think semver implies we need to do all that. If it's an internal package we can have a meaningful (semver) version number while also not documenting it. Following semver doesn't imply we make the package public. We could also just leave it at version 0.x, which semver defines as basically "do anything you want" (point 4 of semver). |
@Janpot Yes, it's not great, this work was never prioritized. The shaping page that centralizes the discussions on this topic: https://www.notion.so/mui-org/mui-utils-purpose-9a9fc9da3a004864b6c4e1f4d1f24f95. |
@romgrk this makes sense to me. Essentially have 2 packages, |
I ported the hook to To build save/store grid state on top of this, it will need to be wrapped with parsing/serialization/validation logic. The hook doesn't mean to be opinionated about parsing, error handling and migrating stored values. |
So, I did try to fix this, but apparently the mechanism for storing works, but the In the video below it can be observed, that the state I get from Screen.Recording.2024-03-07.at.10.57.56.mov |
I have literally no idea why the state does not get applied in the docs ... I tried to with a lot of different approaches, but it won't work. It does work perfectly in the playground and in stackblitz 🤯 |
Weird. Maybe the vibrations aren't harmonious enough in the docs. But it also feels like it could be a datagrid bug, not necessarily a docs issue. |
+1 on this: we noticed this issue turned a bit stale/inactive, but it is still affecting our application that is very DataGrid heavy. Our users particularly want the column visibility, order, and widths to persist on page refresh/navigation from their own preference and choice, which the Save and Restore state is exactly what we need for this. See demo over on: #13963 |
I think the reason is point (3) from the issue description. |
Summary
This is a continuation of #7876. The demo https://next.mui.com/x/react-data-grid/state/#save-and-restore-the-state-from-external-storage is a good starting point but I don't feel that is good enough. I see 3 problems/opportunities:
Screen.Recording.2024-01-04.at.16.52.59.mov
Examples
No response
Motivation
No response
Search keywords: Save and restore the state from external storage
The text was updated successfully, but these errors were encountered: