Skip to content

Commit

Permalink
[7811] Fix row heights not changing on gridStyle or `rowHeightsOpti…
Browse files Browse the repository at this point in the history
…ons.lineHeight` change

- requires waterfalling `gridStyles` down to EuiDataGridCell
  • Loading branch information
cee-chen committed Sep 14, 2024
1 parent 32c984d commit 0d8b6ed
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ describe('EuiDataGridCell', () => {
),
popoverContext: mockPopoverContext,
rowHeightUtils: mockRowHeightUtils,
gridStyles: {},
};

beforeEach(() => jest.clearAllMocks());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,11 @@ export class EuiDataGridCell extends Component<

if (
this.props.rowHeightsOptions?.defaultHeight !==
prevProps.rowHeightsOptions?.defaultHeight
prevProps.rowHeightsOptions?.defaultHeight ||
this.props.rowHeightsOptions?.lineHeight !==
prevProps.rowHeightsOptions?.lineHeight ||
this.props.gridStyles?.fontSize !== prevProps.gridStyles?.fontSize ||
this.props.gridStyles?.cellPadding !== prevProps.gridStyles?.cellPadding
) {
this.recalculateLineHeight();
}
Expand Down Expand Up @@ -338,6 +342,12 @@ export class EuiDataGridCell extends Component<
if (nextProps.width !== this.props.width) return true;
if (nextProps.rowHeightsOptions !== this.props.rowHeightsOptions)
return true;
if (nextProps.gridStyles?.fontSize !== this.props.gridStyles?.fontSize)
return true;
if (
nextProps.gridStyles?.cellPadding !== this.props.gridStyles?.cellPadding
)
return true;
if (nextProps.renderCellValue !== this.props.renderCellValue) return true;
if (nextProps.renderCellPopover !== this.props.renderCellPopover)
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe('Cell', () => {
renderCellValue: () => null,
interactiveCellId: '',
rowHeightUtils: new RowHeightUtils(),
gridStyles: {},
schema: {},
schemaDetectors,
columns: [{ id: 'C' }],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export type CellProps = Pick<
| 'cellContext'
| 'renderCellPopover'
| 'interactiveCellId'
| 'gridStyles'
| 'rowHeightsOptions'
| 'rowHeightUtils'
| 'rowManager'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export const EuiDataGridBodyCustomRender: FunctionComponent<
setRowHeight,
rowHeightsOptions,
rowHeightUtils,
gridStyles,
};
}, [
schema,
Expand All @@ -161,6 +162,7 @@ export const EuiDataGridBodyCustomRender: FunctionComponent<
setRowHeight,
rowHeightsOptions,
rowHeightUtils,
gridStyles,
]);

const Cell = useCallback<EuiDataGridCustomBodyProps['Cell']>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ export const EuiDataGridBodyVirtualized: FunctionComponent<EuiDataGridBodyProps>
rowManager,
pagination,
headerRowHeight,
gridStyles,
};
}, [
schemaDetectors,
Expand All @@ -357,6 +358,7 @@ export const EuiDataGridBodyVirtualized: FunctionComponent<EuiDataGridBodyProps>
rowManager,
pagination,
headerRowHeight,
gridStyles,
]);

const rowWrapperContextValue = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const EuiDataGridFooterRow = memo(
visibleRowIndex,
interactiveCellId,
popoverContext,
gridStyles,
};

return (
Expand Down
1 change: 1 addition & 0 deletions packages/eui/src/components/datagrid/data_grid_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@ export interface EuiDataGridCellProps {
rowHeightUtils?: RowHeightUtilsType;
rowManager?: EuiDataGridRowManager;
pagination?: Required<EuiDataGridPaginationProps>;
gridStyles: EuiDataGridStyle;
}

export interface EuiDataGridCellState {
Expand Down

0 comments on commit 0d8b6ed

Please sign in to comment.