-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[data grid] processRowUpdate
does not get fired when grid is styled using styled
from @mui/material/styles
#13650
Comments
I found out, that styled DataGrid fire processRowUpdate if there is not used rowModesModel & onRowModesModelChange. When used normal DataGrid, not styled, it is fired also with using own modes model. |
Hi @hlavacz, thanks for bringing this issue to our attention, I have managed to reproduce it using the code provided. As a temporary workaround whilst we look into the issue, you could apply styles to the data grid using the <DataGrid
rows={rows}
columns={columns}
editMode="row"
rowModesModel={rowModesModel}
onRowModesModelChange={handleRowModesModelChange}
onRowEditStop={handleRowEditStop}
processRowUpdate={processRowUpdate}
slots={{
toolbar: EditToolbar as GridSlots['toolbar'],
}}
slotProps={{
toolbar: { setRows, setRowModesModel },
}}
sx={(theme) => ({
'& .rigel-row-blue': {
backgroundColor: getBackgroundColor(theme.palette.info.main, theme.palette.mode),
'&:hover': {
backgroundColor: getHoverBackgroundColor(theme.palette.info.main, theme.palette.mode),
},
'&.Mui-selected': {
backgroundColor: getSelectedBackgroundColor(
theme.palette.info.main,
theme.palette.mode,
),
'&:hover': {
backgroundColor: getSelectedHoverBackgroundColor(
theme.palette.info.main,
theme.palette.mode,
),
},
},
},
})}
/> |
processRowUpdate
does not get fired when grid is styled using styled
from @mui/material/styles
Hi @hlavacz const Component1 = () => {
// ❌ new component is created on every rerender
const Component2 = () => <div>Component 2</div>;
return <Component2 />
} // ✅ the component is defined once
const Component2 = () => <div>Component 2</div>;
const Component1 = () => {
return <Component2 />
} Here's a fixed demo based on the code provided: https://codesandbox.io/s/pensive-newton-rwtgph?file=/src/Demo.tsx |
@hlavacz: 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. |
Steps to reproduce
It is not working even on examples on Docs, when combined. Like:
Minimal reproduction example: https://codesandbox.io/s/zealous-burnell-fm5pnx?file=/src/Demo.tsx
Original code
Current behavior
If it is used DataGrid, processRowUpdate is fired, when StyleDataGrid it is not.
Expected behavior
Fired in both cases.
Context
I think it is very obvioius, but if any details needed, let me know.
Your environment
npx @mui/envinfo
Search keywords: mui datagrid styled processRowUpdate
Order ID: 78140
The text was updated successfully, but these errors were encountered: