mui-x
mui-x copied to clipboard
[DataGrid] Call `preProcessEditCellProps` on blur
I solved #5009 by adding a new method called ensurePreProcessEditCellPropsRanOnce (I'm open for better names) which internally calls setEditCellValue with the current value to force preProcessEditCellProps to run again. I updated all edit components to call this method on blur, like react-final-form does. The solution is similar to https://github.com/mui/mui-x/issues/5009#issuecomment-1139169542.
CodeSandbox: https://codesandbox.io/s/data-grid-community-forked-gk0cl8?file=/src/App.tsx
In the CodeSandbox above, clicking Save and Edit in sequence will call processRowUpdate for the 2nd row. The 1st row will not be saved because preProcessEditCellProps added an error.
Closes #5009
These are the results for the performance tests:
| Test case | Unit | Min | Max | Median | Mean | σ |
|---|---|---|---|---|---|---|
| Filter 100k rows | ms | 312.6 | 594.8 | 498.7 | 454.08 | 109.085 |
| Sort 100k rows | ms | 501.8 | 1,000.2 | 590.9 | 751.76 | 181.757 |
| Select 100k rows | ms | 147 | 315.4 | 219 | 237.06 | 67.851 |
| Deselect 100k rows | ms | 129.9 | 215 | 200.9 | 190.42 | 30.821 |
Generated by :no_entry_sign: dangerJS against 1dab075a3e0fda8c554d9f96e891aadea212d508
This pull request has conflicts, please resolve those before we can evaluate the pull request.
This pull request has conflicts, please resolve those before we can evaluate the pull request.
This pull request has conflicts, please resolve those before we can evaluate the pull request.
I'm closing this one because we have not received more feedback in #5009 and the solution proposed here is just a wrapper around apiRef.current.setEditCellValue. If users ask again for this feature we can expose apiRef.current.runPreProcessEditCellProps which they can use inside an effect that only runs on mount.