-
-
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
[docs] Add recipe for single-click editing #8365
Conversation
Netlify deploy previewNetlify deploy preview: https://deploy-preview-8365--material-ui-x.netlify.app/ Updated pagesThese are the results for the performance tests:
|
// Revert the mode of the other cells from other rows | ||
...Object.keys(prevModel).reduce( | ||
(acc, id) => ({ | ||
...acc, | ||
[id]: Object.keys(prevModel[id]).reduce( | ||
(acc2, field) => ({ | ||
...acc2, | ||
[field]: { mode: GridCellModes.View }, | ||
}), | ||
{}, | ||
), | ||
}), | ||
{}, | ||
), |
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.
Wouldn't excluding the rows/cells from the cellModesModel
exit the editing mode?
In https://deploy-preview-8365--material-ui-x.netlify.app/x/react-data-grid/editing/#controlled-mode it says:
The options passed to both model props only take effect when mode changes. Updating the params of a cell or row, but keeping the same mode, makes the cell or row to stay in the same mode. Also, removing one field or row ID from the object will not cause the missing cell or row to go to "view" mode.
But I have tried removing them from the model and didn't notice any difference:
https://codesandbox.io/s/festive-raman-qz19hf?file=/demo.tsx
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.
Yes, only removing the row is enough if only a cell is allowed to be editable at a time. If multiple cells can be edited at the same time, then we can't remove the row. This demo implements the most broader scenario, allowing further customization.
The code sample in this recipe suffers from a bug where the initial value is lost if the cell edit is initiated from an api call to startCellEditMode() which passes an initialValue property. I have linked a sample fix to #2186 (comment) . For convenience here's the direct link as well. https://codesandbox.io/s/material-demo-forked-c0ldcq?file=/demo.tsx |
Thank you for looking into adding a demo for this! I have been using this workaround but found a small issue when upgrading to v6 with single select edit cells: Once the select cell menu is open, clicking away does not close/change back to view mode Reproduction: https://codesandbox.io/s/material-demo-forked-wco42h?file=/demo.tsx It seems like the click event on the backdrop is passing through and triggering
|
Closes #2186