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

[DataGrid] Clean params of onCellEditCommit #3693

Merged
merged 3 commits into from Jan 25, 2022

Conversation

valenfv
Copy link
Contributor

@valenfv valenfv commented Jan 22, 2022

Fixes #3442.

The issue

The params sent toonCellEditCommit callback function either when clicking outside or pressing Enter / Tab, were inconsistent.

The solution

Clean the params to only contain {id, field, value}

When clicking outside of a cell in editing state, the params sent to the publishEvent are now the same as the ones sent when tabbing or pressing enter.

  • Given the following instance:
    <DataGrid onCellEditCommit={e => console.log(e)} rows={rows} columns={columns} />
  1. Edit a row and click outside
  2. Edit a row and press Enter/Tab

Actual results: id, field and value are the fields received in the params

image

Solution provided by @alexfauquette

@mui-bot
Copy link

mui-bot commented Jan 22, 2022

These are the results for the performance tests:

Test case Unit Min Max Median Mean σ
Filter 100k rows ms 181.1 392.1 312.2 300.02 83.367
Sort 100k rows ms 348.7 872.2 746.5 698.04 184.667
Select 100k rows ms 161.2 381.3 302.8 279.16 74.487
Deselect 100k rows ms 132.5 380.2 200.2 236.36 87.395

Generated by 🚫 dangerJS against 112e666

@alexfauquette
Copy link
Member

Thanks for your contribution :)

@DanailH The code looks good to me, but it is a solution I proposed in an issue. Could you check that it is not a problem to remove some information here?

@flaviendelangle
Copy link
Member

flaviendelangle commented Jan 24, 2022

ping @m4theushw

@m4theushw
Copy link
Member

Looks good to me. I merged with master to fix argos.

@alexfauquette alexfauquette changed the title [DataGrid] Commit params cleaned [DataGrid] Clean params of onCellEditCommit Jan 25, 2022
@alexfauquette alexfauquette merged commit e87f6ba into mui:master Jan 25, 2022
@cherniavskii cherniavskii added component: data grid This is the name of the generic UI component, not the React module! feature: Editing Related to the data grid Editing feature labels Feb 3, 2022
@zigang93
Copy link
Contributor

is this props onCellEditCommit been removed in v6?

@m4theushw
Copy link
Member

@zigang93 Yes, you can use processRowUpdate for similar behavior. See https://mui.com/x/react-data-grid/editing/#persistence

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! feature: Editing Related to the data grid Editing feature
Projects
None yet
7 participants