Skip to content

Commit

Permalink
[DataGridPremium] Fix boolean cell not rendered in group rows (#12492)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Cherniavskyi <[email protected]>
  • Loading branch information
sai6855 and cherniavskii authored Mar 21, 2024
1 parent 4280655 commit fb7e03e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,22 @@ describe('<DataGridPremium /> - Row grouping', () => {
expect(getColumnValues(0)).to.deep.equal(['Cat A (3)', '', '', '', 'Cat B (2)', '', '']);
});

it('should display icon on auto-generated row', () => {
render(
<Test
initialState={{
rowGrouping: {
model: ['isFilled'],
},
}}
columns={[...baselineProps.columns, { field: 'isFilled', type: 'boolean' }]}
rows={baselineProps.rows.map((row) => ({ ...row, isFilled: false }))}
/>,
);

expect(screen.getByTestId('CloseIcon')).toBeVisible();
});

it('should respect the grouping criteria with colDef.groupable = false', () => {
render(
<Test
Expand Down
10 changes: 6 additions & 4 deletions packages/x-data-grid/src/components/cell/GridBooleanCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ const useUtilityClasses = (ownerState: OwnerState) => {
return composeClasses(slots, getDataGridUtilityClass, classes);
};

interface GridBooleanCellProps
extends GridRenderCellParams,
Omit<SvgIconProps, 'tabIndex' | 'id'> {}
interface GridBooleanCellProps extends GridRenderCellParams, Omit<SvgIconProps, 'tabIndex' | 'id'> {
hideDescendantCount?: boolean;
}

function GridBooleanCellRaw(props: GridBooleanCellProps) {
const {
Expand All @@ -40,6 +40,7 @@ function GridBooleanCellRaw(props: GridBooleanCellProps) {
isEditable,
hasFocus,
tabIndex,
hideDescendantCount,
...other
} = props;

Expand Down Expand Up @@ -108,6 +109,7 @@ GridBooleanCellRaw.propTypes = {
* If true, the cell is the active element.
*/
hasFocus: PropTypes.bool.isRequired,
hideDescendantCount: PropTypes.bool,
/**
* The grid row id.
*/
Expand Down Expand Up @@ -140,7 +142,7 @@ const GridBooleanCell = React.memo(GridBooleanCellRaw);
export { GridBooleanCell };

export const renderBooleanCell: GridColDef['renderCell'] = (params: GridBooleanCellProps) => {
if (isAutoGeneratedRow(params.rowNode)) {
if (params.field !== '__row_group_by_columns_group__' && isAutoGeneratedRow(params.rowNode)) {
return '';
}

Expand Down

0 comments on commit fb7e03e

Please sign in to comment.