[DataGrid] rowModesModel is not really usable as controlled property #11423
Labels
bug 🐛
Something doesn't work
component: data grid
This is the name of the generic UI component, not the React module!
Steps to reproduce
Link to live example: (required)
Steps:
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 withid
needs to return to the default mode ofGridRowModes.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 therowModesModel
is derived from other state in the component. In a controlled scenario, one would expect that the grid reflects the state as presented inrowModesModel
, 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.tsxYour environment
npx @mui/envinfo
Search keywords: rowModesModel
The text was updated successfully, but these errors were encountered: