Skip to content

Commit

Permalink
Fix cell links not being applied with non-expansion positioning styles (
Browse files Browse the repository at this point in the history
  • Loading branch information
CarsonF authored Oct 2, 2024
1 parent 67d4686 commit ec9ca0d
Showing 1 changed file with 24 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Box } from '@mui/material';
import {
DataGridProProps as DataGridProps,
GridColDef,
GridRenderCellParams,
GridRowId,
GridToolbarColumnsButton,
Expand All @@ -26,32 +27,37 @@ import {

const COLLAPSED_ROW_HEIGHT = 54;

// Position cell text consistently regardless of expansion
const NonExpansionCell = ({ formattedValue }: GridRenderCellParams) => (
<Box
sx={{
// Causes row to grow by 1px on row height auto
// Shift the 1px to padding to prevent.
height: COLLAPSED_ROW_HEIGHT - 1,
pt: '1px',
// Text shifts by a pixel without this - any value works
lineHeight: 1,
const wrapForNonExpansion = (renderCell?: GridColDef['renderCell']) => {
// Position cell text consistently regardless of expansion
const NonExpansionCell = (props: GridRenderCellParams) => (
<Box
sx={{
// Causes row to grow by 1px on row height auto
// Shift the 1px to padding to prevent.
height: COLLAPSED_ROW_HEIGHT - 1,
pt: '1px',
// Text shifts by a pixel without this - any value works
lineHeight: 1,

display: 'flex',
alignItems: 'center',
}}
>
{formattedValue}
</Box>
);
display: 'flex',
alignItems: 'center',
}}
>
{renderCell ? renderCell(props) : props.formattedValue ?? props.value}
</Box>
);
return NonExpansionCell;
};

const columns = entries(ProgressReportsColumnMap).map(([name, col]) => ({
field: name,
...col,
...(!(
'cellClassName' in col && col.cellClassName.includes(ExpansionMarker)
) && {
renderCell: NonExpansionCell,
renderCell: wrapForNonExpansion(
'renderCell' in col ? col.renderCell : undefined
),
}),
}));

Expand Down

0 comments on commit ec9ca0d

Please sign in to comment.