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] rowModesModel is not really usable as controlled property #11423

Closed
Janpot opened this issue Dec 15, 2023 · 3 comments · Fixed by #13056
Closed

[DataGrid] rowModesModel is not really usable as controlled property #11423

Janpot opened this issue Dec 15, 2023 · 3 comments · Fixed by #13056
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module!

Comments

@Janpot
Copy link
Member

Janpot commented Dec 15, 2023

Steps to reproduce

Link to live example: (required)

Steps:

  1. Open the example: https://stackblitz.com/edit/react-m6fhje?file=Demo.tsx
  2. Click the edit button
  3. CLick the close button

Current behavior

The rowModesModel is reset to {}, but the grid doesn't reflect this change.

Expected behavior

When the rowModesModel is changed from { [id]: GridRowModes.Edit } back to {}, the row with id needs to return to the default mode of GridRowModes.View.

Context

Currently it's not possible to use rowModesModel as a controlled property without knowing the actual state of the grid. This is problematic in the scenario of the referenced example, where the rowModesModel is derived from other state in the component. In a controlled scenario, one would expect that the grid reflects the state as presented in rowModesModel, and does not present different behavior depending on the previous values of this property.

This behavior goes against the idea of a single source of truth for each state

Overall, I'm looking for a reliable setup in which only 1 row can be editable at a time

Edit: For now it seems I can work around this by patching the rowModesModel with values from the previous render. In case it could help anybody: https://stackblitz.com/edit/react-m6fhje-31blaf?file=Demo.tsx

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: rowModesModel

@Janpot Janpot added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 15, 2023
@zannager zannager added the component: data grid This is the name of the generic UI component, not the React module! label Dec 15, 2023
@Janpot Janpot changed the title rowModesModel is only usable as controlled property when the actual state is known rowModesModel is not really usable as controlled property Dec 15, 2023
@michelengelen michelengelen changed the title rowModesModel is not really usable as controlled property [DataGrid] rowModesModel is not really usable as controlled property Dec 18, 2023
@michelengelen
Copy link
Member

@romgrk I remember you wrote something about listening on (slices of) state this weekend in slack. Would this relate to that?

@michelengelen michelengelen removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 20, 2023
@romgrk romgrk added the bug 🐛 Something doesn't work label Mar 21, 2024
@romgrk
Copy link
Contributor

romgrk commented Mar 21, 2024

No I don't think it's related.

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.

@Janpot: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: data grid This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants