-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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] Prevent commit if preProcessEditCellProps
resolves with an error
#3612
Conversation
1f010a7
to
94e38da
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
These are the results for the performance tests:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If preventCommitWhileValidating
is temporary, maybe we could put it under experimentalFeatures
?
Or at least explain on the doc that we only add this strange prop temporarily to avoid any breaking change and that it will be removed on v6.
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
@flaviendelangle I moved to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@m4theushw yes for the row grouping, disableRowGrouping
made sense even when the feature will be marked as stable.
Fixes #3304
Before: https://codesandbox.io/s/datagridpro-v5-quick-start-forked-pxc4e?file=/src/App.tsx
After: https://codesandbox.io/s/datagridpro-v5-quick-start-forked-rzyrl?file=/src/App.tsx
The bug happens because we don't keep a track if the validation is running or not. With
singleSelect
, thepreProcessEditCellProps
is called when the value is changed and also when commiting, which occur at the same time in this component. To fix it, we should have a flag tracking when the validation is running or not. If it's running, we don't commit the value nor call the callback again. To properly implement this, it involves changing the state which, since the state is passed to all edit components as props, could cause a warning if users spread the props directly into the DOM node without sanitizing them. Since we can't release that breaking change, I added temporarily a new prop calledpreventCommitWhileValidating
for users to opt-in. Once it's enabled, we update theisValidating
prop in the editing state before and after callingpreProcessEditCellProps
. During commit we check if it's validating or not. In v6 I want to make that the default behavior and remove the temp prop.The code is very ugly. There're opportunities to refactor it but it's better to do it after #3219.
If you open the CodeSandbox above, you may notice that it only updates the Select value after
preProcessEditCellProps
has resolved. That's another PR.