Skip to content

Commit

Permalink
[data grid] Fix column definition undefined value (mui#14456)
Browse files Browse the repository at this point in the history
  • Loading branch information
sai6855 authored Sep 30, 2024
1 parent f100d15 commit 0f0a7ec
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
20 changes: 20 additions & 0 deletions packages/x-data-grid-pro/src/tests/filtering.DataGridPro.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,26 @@ describe('<DataGridPro /> - Filter', () => {
expect(getColumnHeaderCell(0, 1).textContent).to.equal('Custom Input');
});

it('should not cause unexpected behavior when props are explictly set to undefined', () => {
expect(() => {
render(
<TestCase
columns={[
{
field: 'actions',
headerName: 'Actions',
type: 'actions',
width: 80,
filterOperators: undefined,
getActions: () => [<React.Fragment>action</React.Fragment>],
},
]}
headerFilters
/>,
);
}).not.toErrorDev();
});

// See https://github.com/mui/mui-x/issues/13217
it('should not throw when custom filter operator is used with an initilaized value', () => {
expect(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import resolveProps from '@mui/utils/resolveProps';
import {
GridColumnLookup,
GridColumnsState,
Expand Down Expand Up @@ -379,11 +380,7 @@ export const createColumnsState = ({
}
});

columnsState.lookup[field] = {
...existingState,
...newColumn,
hasBeenResized,
};
columnsState.lookup[field] = resolveProps(existingState, { ...newColumn, hasBeenResized });
});

if (keepOnlyColumnsToUpsert && !isInsideStateInitializer) {
Expand Down

0 comments on commit 0f0a7ec

Please sign in to comment.