mui-x icon indicating copy to clipboard operation
mui-x copied to clipboard

[DataGrid] Call `preProcessEditCellProps` on blur

Open m4theushw opened this issue 3 years ago • 2 comments
trafficstars

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

m4theushw avatar Jun 22 '22 22:06 m4theushw

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

mui-bot avatar Jun 22 '22 22:06 mui-bot

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

github-actions[bot] avatar Jul 29 '22 13:07 github-actions[bot]

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

github-actions[bot] avatar Aug 11 '22 21:08 github-actions[bot]

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

github-actions[bot] avatar Sep 01 '22 10:09 github-actions[bot]

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.

m4theushw avatar Dec 02 '22 21:12 m4theushw