Skip to content

Commit

Permalink
[data grid] Fix column definition undefined value (#14456)
Browse files Browse the repository at this point in the history
sai6855 authored Sep 30, 2024

Verified

This commit was signed with the committer’s verified signature.
pradyunsg Pradyun Gedam
1 parent f100d15 commit 0f0a7ec
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
@@ -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(() => {
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,
@@ -379,11 +380,7 @@ export const createColumnsState = ({
}
});

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

if (keepOnlyColumnsToUpsert && !isInsideStateInitializer) {

0 comments on commit 0f0a7ec

Please sign in to comment.