Skip to content
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

feat(mui): editable Data Grid #5744 #5989

Merged

Conversation

lnikitadobrenkol
Copy link
Contributor

Bugs / Features

This PR introduces the ability to make MUI Data Grid columns editable by setting an editable property on specific column definitions.

What is the current behavior?

Currently, the MUI Data Grid does not support inline editing directly through configuration.

What is the new behavior?

With the changes in this PR, developers can now configure columns to be editable directly from the MUI Data Grid setup, enhancing the grid's flexibility for various use cases.

fixes # (5656)

Notes for reviewers

I have extensively tested the functionality introduced in this PR, primarily based on the initial implementation by @beg1c. After setting up a test project to integrate the enhanced dataGridHook, it has met the expected outcomes. I encourage a thorough review to ensure that all aspects of the new editable feature align with our project standards and user requirements. Please provide feedback or suggest improvements if you identify potential enhancements or adjustments. I am open to discussions and willing to make any necessary changes to perfect this feature.

@lnikitadobrenkol lnikitadobrenkol requested a review from a team as a code owner May 26, 2024 09:56
Copy link

changeset-bot bot commented May 26, 2024

🦋 Changeset detected

Latest commit: 8cb1394

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@refinedev/mui Minor
@refinedev/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@aliemir aliemir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @lnikitadobrenkol thank you for the PR! Do you think using useForm has any advantages over useUpdate in this specific case? Since useForm features are mostly disabled and action is hardcoded to "edit", I think we can use useUpdate and have a simpler implementation by omitting id and setId 🤔

@lnikitadobrenkol
Copy link
Contributor Author

Hello @aliemir
I've been working on enhancing the useDataGrid hook to handle errors and state more robustly, specifically around reverting to original data when updates fail. However, I’m stuck with an issue where, despite the update operation being rejected (we simulate this in tests), the function still returns the modified data instead of the original.

Here’s the quick rundown:
Function: processRowUpdate
Expected: Return old data on update failure.
Actual: It returns the new, incorrect data.

I’ve spent quite a few hours on this and tried various fixes, but no luck so far. Could you please help me with this – any commits, examples, ideas or suggestions would be greatly appreciated!
We can arrange a short call if needed - so I can share the screen to show what exactly I am doing, (maybe I completely on the wrong direction)

Copy link

@chatpong-v chatpong-v left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To update feature

@lnikitadobrenkol
Copy link
Contributor Author

@BatuhanW @aliemir Hey guys! I need your help in implementing useUpdate. Please have a look

@aliemir
Copy link
Member

aliemir commented Jun 1, 2024

Hey @lnikitadobrenkol i'll try to check your comment today and get back to you 🙏

@lnikitadobrenkol
Copy link
Contributor Author

lnikitadobrenkol commented Jun 1, 2024

Hi @aliemir, I think I was finally able to resolve the issue and updated the PR 👾! Please review the latest commit and let me know if further adjustments are needed. I would appreciate your feedback to ensure everything meets the standards.
And I would need a help with the cypress end-to-end test for sure, I have almost no experience writing them

Copy link
Member

@aliemir aliemir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @lnikitadobrenkol thank you for the updates! Looks great! I've just left couple of comments to improve the usage and remove some unnecessary stuff. Can you work on those?

I'll also try to check the e2e tests and provide a review for it 🚀

Thanks again for the great work 👏 👏

packages/mui/src/hooks/useDataGrid/index.ts Outdated Show resolved Hide resolved
packages/mui/src/hooks/useDataGrid/index.ts Outdated Show resolved Hide resolved
packages/mui/src/hooks/useDataGrid/index.ts Outdated Show resolved Hide resolved
packages/mui/src/hooks/useDataGrid/index.ts Outdated Show resolved Hide resolved
packages/mui/src/hooks/useDataGrid/index.ts Outdated Show resolved Hide resolved
packages/mui/src/hooks/useDataGrid/index.ts Outdated Show resolved Hide resolved
packages/mui/src/hooks/useDataGrid/index.ts Outdated Show resolved Hide resolved
packages/mui/src/hooks/useDataGrid/index.ts Outdated Show resolved Hide resolved
@lnikitadobrenkol
Copy link
Contributor Author

@aliemir Thank you for the detailed review!! It really helps, appreciate it. Sure, I'll have a look at the comments and commit the fix as soon as possible for me

@lnikitadobrenkol
Copy link
Contributor Author

@aliemir I updated the PR based on your feedback. Please have a look and and let me know if we can proceed or more changes are required

@BatuhanW BatuhanW added this to the July Release milestone Jun 4, 2024
@lnikitadobrenkol
Copy link
Contributor Author

@aliemir @BatuhanW @omeraplak Hey guys! I think I found the way to fix cypress e2e tests, just made the commit. Could you please review the PR - and let's fix any problem that are left, and proceed with this issue further?

@aliemir aliemir self-requested a review June 10, 2024 14:21
Copy link
Member

@aliemir aliemir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left two small comments that we can work on. Thank you for the changes, e2e test looks great! I'll also try to test this feature myself in my local 🤞

Let me know if you can work on the comments, if not I can try to take a look at them myself 🙏

@lnikitadobrenkol
Copy link
Contributor Author

Thank you! I'll have a look at the comments and work on the fix this week.
Sure, please let me know how you find this feature locally and if there is anything we can improve

@lnikitadobrenkol
Copy link
Contributor Author

@aliemir hello! I implemented the changes you suggested, please have a look

Copy link
Member

@aliemir aliemir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @lnikitadobrenkol found some issues with the implementation and the example was using a custom processRowUpdate rather than the one from useDataGrid, was that intentional?

Updated the code for processRowUpdate and updated the example code. While doing so, also had a small update in the core package to export the required types and updated the type import for UseUpdateProps.

@aliemir aliemir linked an issue Jun 14, 2024 that may be closed by this pull request
@lnikitadobrenkol
Copy link
Contributor Author

lnikitadobrenkol commented Jun 14, 2024

Hey @aliemir!
No, it was not intentional - I guess I missed it somehow.
Thank you for spotting it, and doing other updates - looks great!

@lnikitadobrenkol
Copy link
Contributor Author

@aliemir What do you think - are we ready to merge the PR or there is something else left to work on?

@lnikitadobrenkol
Copy link
Contributor Author

@aliemir @BatuhanW
Could you please review this PR whenever it's convenient for you and let me know if it's ready to be merged? I'd love to include this feature in the July release. I'll be on vacation from June 22-29, so if any changes are needed, it would be great to address them this week.

@aliemir
Copy link
Member

aliemir commented Jun 20, 2024

Hey @lnikitadobrenkol We'll merge this PR to be included in our next release. In the context of this feature, we don't require any additional changes, thank you for your contribution 🙏

@BatuhanW BatuhanW changed the base branch from master to releases/july June 20, 2024 08:46
@BatuhanW BatuhanW merged commit b86648f into refinedev:releases/july Jun 20, 2024
21 checks passed
@BatuhanW BatuhanW mentioned this pull request Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] Editable MUI Data Grid
4 participants