Skip to content

[data grid] editing with getRowId for custom id field issue #17030

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

Closed
roastnewt opened this issue Mar 18, 2025 · 9 comments · Fixed by #17048
Closed

[data grid] editing with getRowId for custom id field issue #17030

roastnewt opened this issue Mar 18, 2025 · 9 comments · Fixed by #17048
Assignees
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 regression A bug, but worse

Comments

@roastnewt
Copy link

roastnewt commented Mar 18, 2025

Steps to reproduce

Steps:

  1. Open this link to live example: https://codesandbox.io/p/devbox/polished-framework-x4fzg7
  2. Double click to edit a row
  3. Hit enter or clickaway to stop editing
  4. Get TypeError: row is null

Current behavior

Datagrid - Editing a row with a custom rowId field and saving throws an error, and the row stays in edit mode

This started occurring when we updated from datagrid premium 7.27.3 to 7.28.0

Expected behavior

Clicking away / hitting enter should save the row and be back in view mode

Context

No response

Your environment

npx @mui/envinfo
   System:
    OS: Windows 11 10.0.22631
  Binaries:
    Node: 22.12.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.9.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: Not Found
  Browsers:
    Chrome: Not Found
    Edge: Chromium (127.0.2651.74)
  npmPackages:
    @emotion/react:  11.11.4
    @emotion/styled:  11.10.6
    @mui/core-downloads-tracker:  6.4.8
    @mui/icons-material: ^6.4.8 => 6.4.8
    @mui/material: ^6.1.1 => 6.4.8
    @mui/private-theming:  6.4.8
    @mui/styled-engine:  6.4.8
    @mui/system:  6.4.8
    @mui/types:  7.2.24
    @mui/utils:  6.4.8
    @mui/x-data-grid:  7.28.0
    @mui/x-data-grid-premium: ^7.27.3 => 7.28.0
    @mui/x-data-grid-pro:  7.28.0
    @mui/x-date-pickers:  7.28.0
    @mui/x-date-pickers-pro: ^7.27.3 => 7.28.0
    @mui/x-internals:  7.28.0
    @mui/x-license:  7.28.0
    @types/react: ^19.0.11 => 19.0.11
    react: ^19.0.0 => 19.0.0
    react-dom: ^19.0.0 => 19.0.0
    typescript: ^5.8.2 => 5.8.2

Search keywords: getRowId null edit datagrid save

Order ID or Support key 💳 (optional)

75070

@roastnewt roastnewt added bug 🐛 Something doesn't work status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Mar 18, 2025
@github-actions github-actions bot added the component: data grid This is the name of the generic UI component, not the React module! label Mar 18, 2025
@arminmeh
Copy link
Contributor

hey @roastnewt
I can't access your sandbox.
can you update the permissions?

@arminmeh arminmeh added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Mar 19, 2025
@roastnewt
Copy link
Author

Whoops! Fixed

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Mar 19, 2025
@michelengelen michelengelen changed the title Datagrid editing with getRowId for custom id field issue [data grid] editing with getRowId for custom id field issue Mar 19, 2025
@michelengelen
Copy link
Member

michelengelen commented Mar 19, 2025

Hey @roastnewt ... It seems thegetRowWithUpdatedValuesFromRowEditing function is getting called with the wrong id. This diff fixes it, but i would like a second look from another dev from the team on this:

--- a/packages/x-data-grid/src/hooks/features/editing/useGridRowEditing.ts
+++ b/packages/x-data-grid/src/hooks/features/editing/useGridRowEditing.ts
@@ -535,7 +535,7 @@ export const useGridRowEditing = (
         return;
       }

-      const rowUpdate = apiRef.current.getRowWithUpdatedValuesFromRowEditing(row.id);
+      const rowUpdate = apiRef.current.getRowWithUpdatedValuesFromRowEditing(id);

       if (processRowUpdate) {
         const handleError = (errorThrown: any) => {

cc @arminmeh

@michelengelen michelengelen removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Mar 19, 2025
@github-project-automation github-project-automation bot moved this to 🆕 Needs refinement in MUI X Data Grid Mar 19, 2025
@michelengelen michelengelen added the feature: Editing Related to the data grid Editing feature label Mar 19, 2025
@arminmeh arminmeh self-assigned this Mar 20, 2025
@arminmeh arminmeh moved this from 🆕 Needs refinement to 🏗 In progress in MUI X Data Grid Mar 20, 2025
@arminmeh
Copy link
Contributor

@michelengelen what are the differences in v8 to make this work as is?

@michelengelen
Copy link
Member

michelengelen commented Mar 20, 2025

@michelengelen what are the differences in v8 to make this work as is?

Oh, I forgot to update the comment. This actually did not work when I updated all dependencies (fresh install).

@arminmeh
Copy link
Contributor

I'll look into this

@arminmeh
Copy link
Contributor

Your proposal is fine @michelengelen
I will open a PR with the fix

@arminmeh arminmeh added regression A bug, but worse and removed bug 🐛 Something doesn't work labels Mar 20, 2025
Copy link

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

@arminmeh arminmeh moved this from 🏗 In progress to ✅ Done in MUI X Data Grid Mar 21, 2025
@roastnewt
Copy link
Author

Thank you @arminmeh @michelengelen for the quick turnaround and fix, it is very much appreciated

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 regression A bug, but worse
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants