-
-
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] Add row editing feature #2098
Conversation
2c4f32c
to
ae65c54
Compare
0755d87
to
25ed1c9
Compare
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.
It looks like an awesome starting point!
docs/src/pages/components/data-grid/editing/FullFeaturedCrudGrid.js
Outdated
Show resolved
Hide resolved
packages/grid/_modules_/grid/hooks/features/rows/useGridEditRows.ts
Outdated
Show resolved
Hide resolved
state.lost.issue.mp4 |
packages/grid/_modules_/grid/hooks/features/rows/useGridEditRows.ts
Outdated
Show resolved
Hide resolved
packages/grid/_modules_/grid/hooks/features/rows/useGridEditRows.ts
Outdated
Show resolved
Hide resolved
packages/grid/_modules_/grid/hooks/features/rows/useGridEditRows.ts
Outdated
Show resolved
Hide resolved
packages/grid/_modules_/grid/hooks/features/rows/useGridEditRows.ts
Outdated
Show resolved
Hide resolved
@oliviertassinari I couldn't reproduce it consistently, it happened almost randomly here. I suppose it loses the state because the time between clicks is too small. There's the first click, the internal state is updated with the new value, then it calls If you open this other demo in local host https://deploy-preview-2098--material-ui-x.netlify.app/components/data-grid/editing/#client-side-validation, the UX of erasing the content of the text input is not good. It's lagging because there's a rerender each time a character is pressed. |
[`${GRID_CSS_CLASS_PREFIX}-row--editing`]: apiRef.current.getRowMode(id) === 'edit', | ||
[`${GRID_CSS_CLASS_PREFIX}-row--editable`]: editMode === 'row', |
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.
Should we move those in the classes constant? Or better yet with GridClasses from here #2320
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.
I'll keep as it is, then after #2320 I change to use gridClasses
.
packages/grid/_modules_/grid/hooks/features/rows/useGridEditRows.ts
Outdated
Show resolved
Hide resolved
I tested it and it is an awesome feature 🚀. The only thing I was able to find is when you add new rows and the rows exceed the overflow of the window you are not automatically scrolled to the newly created row. It makes sense for the user to get scrolled to that row since when you create it it is in |
Now it's scrolling to the new row.
Interesting, we could investigate how to make |
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.
I have personally seen enough. Happy to go to production with the current version. I have left more comments to polish. Great work, well done!
On this demo https://deploy-preview-2098--material-ui-x.netlify.app/components/data-grid/editing/#conditional-validation, the state is lost, sometimes
I have found it using console.warn to get the stack track. It wasn't easy, took me half an hour! The reset happens when the double click triggers. I have pushed a commit 35df73f that replicates the same logic of setCellMode
in setRowMode
. We can skip the whole section if we are already in edit mode. Fixed
It's lagging because there's a rerender each time a character is pressed.
I remember making the same point to Damien in a PR"s review. One possible solution could be to keep the state of the input local, and only sync with the parent data grid on commits.
We could investigate how to make scrollToIndexes support pagination.
We could, maybe we should wait for a developer to complain?
docs/src/pages/components/data-grid/editing/ConditionalValidationGrid.tsx
Outdated
Show resolved
Hide resolved
packages/grid/_modules_/grid/hooks/features/rows/useGridEditRows.ts
Outdated
Show resolved
Hide resolved
packages/grid/_modules_/grid/hooks/features/rows/useGridEditRows.ts
Outdated
Show resolved
Hide resolved
packages/grid/_modules_/grid/hooks/features/rows/useGridEditRows.ts
Outdated
Show resolved
Hide resolved
packages/grid/_modules_/grid/hooks/features/rows/useGridEditRows.ts
Outdated
Show resolved
Hide resolved
🎊 |
Closes #204
Based on #2087
Previews: https://deploy-preview-2098--material-ui-x.netlify.app/components/data-grid/editing/#row-editing
Based on the benchmarks, I think that the easiest path to implement this feature is to leverage the current cell editing, but with the difference that the value is committed once for the entire row, instead of on each cell change. There's already an
editMode
prop which is not being used, so I'm repurposing it to be used to choose betweencell
androw
.TODO
onEditRowChangeCommit
prop