-
-
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] Only update input with value prop if debounce is off #5646
Conversation
These are the results for the performance tests:
|
a49fa27
to
68bf616
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
|
||
let parsedValue = newValue; | ||
if (column.valueParser && rootProps.experimentalFeatures?.newEditingApi) { | ||
parsedValue = column.valueParser(newValue, apiRef.current.getCellParams(id, field)); |
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.
Since we don't sync the value between the global state and the local state, when the call is debounced, we need to manually call the value parser and skip the one in apiRef.current.setEditCellValue
.
Fixes #5283
Preview: https://deploy-preview-5646--material-ui-x.netlify.app/x/react-data-grid/editing/
I don't have a precise explanation of why #5283 happens but I have a hypothesis. On each keystroke we call
apiRef.current.setEditCellValue
which debounces the state updates. When the debounce time expires, the global state is updated triggering a rerender of the entire grid. While the grid is rerendering, sometimes taking a long time, if the user presses another key this last key will be lost because the input value is changed to reflect the value in the state. I solved this problem here by ignoring the sync between the value in the global state and the value in the edit component's state when the reason for this sync to happen is a debounce event. In practical terms,apiRef.current.setEditCellValue
now has areason
argument which can be accessed viaapiRef.current.unstable_getEditCellMeta
.