-
-
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
[DataGrid] Consider bringing back the error overlay #11399
Comments
Thank you @Janpot for raising the issue. IMHO, there was no other obvious reason for removing the error prop along with error boundary other than it being easier to be done on users' side and one less prop to be handled by grid. (@cherniavskii please correct me if I missed something). By the way, I tried to adjust your example with the known |
We discussed this during the weekly meeting – we'll bring back the error overlay (with a dedicated slot) and the |
How will that work when for instance the data is missing an id field? Will it throw an error? Or will it display in the rows area? i.e. when I have a backend error while loading the rows, I'd like to show as much as possible of the grid UI (toolbar, pagination controls, column headers) and just show an error in the area where otherwise the rows would render. In my intuition, and error with the format of the row data would go in there as well. But if the grid throws in that case, this won't be possible. Or at least, I'd like to somehow be able to display missing id error there when Toolpad is in development mode (or cell formatting error,...). |
That's a good question. Yes, it will throw an error and you should be able to catch it in the error boundary: Interestingly, Data Grid v5 that had the error boundary and error overlay doesn't catch it either: https://codesandbox.io/p/sandbox/wizardly-star-8hmr8q?file=%2Fsrc%2FDemo.tsx%3A12%2C22
In Data Grid v5, the error overlay was covering the whole Data Grid: https://stackblitz.com/edit/react-8vqwuz?file=Demo.tsx,package.json,index.tsx
I'm not sure it's possible since the missing Id error is thrown at the top of the Data Grid tree. |
Summary 💡
Mostly useful when doing serverside pagination/filtering. The main suggestion I see on the issue tracker seems to be to create an overlay for the whole grid in case a data loading error happens. The specific use-case where this setup is problematic is the one where the usage of a specific filter results in an error. One could get the grid back to the working state by simply removing the filter. but since the grid has been fully overlaid, one can't access the filter controls anymore. An error overlay that targets specifically the rows area doesn't have this problem.
Illustration of the problem: https://stackblitz.com/edit/react-xffwnt?file=Demo.tsx
in this demo, After adding a filter to this id column, the whole grid disappears behind the error overlay.
In Toolpad at the moment we've hacked around this problem by hijacking the NoRowsOverlay slot, as can be seen in the following demo: https://stackblitz.com/edit/react-xffwnt-ko8kc5?file=Demo.tsx
But this has some limitations (e.g. can't overlay the error over old data).
As a sidenote, error handling is such an important consideration in serverside loading scenarios, yet none of the DataGrid demos take it into account. The fake
useQuery
function simply ignores the fact that this function inreact-query
can return anerror
. In the ideal scenario, errors can be easily displayed in-context, inside of the grid itself. Since MUI X removed theerror
prop, we've really had to build a lot of machinery in Toolpad to handle serverside errors. Personally I don't understand why this property was removed. I now have to wrap every grid in an error boundary + a separate overlay for row loading errors. It's quite inconvenient.Examples 🌈
No response
Motivation 🔦
No response
Search keywords: error overlay
The text was updated successfully, but these errors were encountered: