From 9f0996d18e27eb261427719564e97a799d3d80f6 Mon Sep 17 00:00:00 2001 From: Lene Gadewoll Date: Tue, 4 Jun 2024 19:03:49 +0200 Subject: [PATCH] chore: revert gridStyles update fix --- .../datagrid/body/cell/data_grid_cell.tsx | 4 -- .../body/cell/data_grid_cell_wrapper.tsx | 4 -- .../body/data_grid_body_virtualized.tsx | 9 +---- .../components/datagrid/data_grid_types.ts | 1 - .../components/datagrid/utils/cell_heights.ts | 38 ------------------- 5 files changed, 1 insertion(+), 55 deletions(-) delete mode 100644 packages/eui/src/components/datagrid/utils/cell_heights.ts diff --git a/packages/eui/src/components/datagrid/body/cell/data_grid_cell.tsx b/packages/eui/src/components/datagrid/body/cell/data_grid_cell.tsx index 7e17f18e407..2f019022b8f 100644 --- a/packages/eui/src/components/datagrid/body/cell/data_grid_cell.tsx +++ b/packages/eui/src/components/datagrid/body/cell/data_grid_cell.tsx @@ -318,10 +318,6 @@ export class EuiDataGridCell extends Component< this.recalculateLineHeight(); } - if (this.props?.shouldUpdateLineHeight === true) { - this.recalculateLineHeight(); - } - if ( (this.props.rowHeightUtils as RowHeightVirtualizationUtils) ?.compensateForLayoutShift && diff --git a/packages/eui/src/components/datagrid/body/cell/data_grid_cell_wrapper.tsx b/packages/eui/src/components/datagrid/body/cell/data_grid_cell_wrapper.tsx index 97779393f57..a95f327a73e 100644 --- a/packages/eui/src/components/datagrid/body/cell/data_grid_cell_wrapper.tsx +++ b/packages/eui/src/components/datagrid/body/cell/data_grid_cell_wrapper.tsx @@ -75,7 +75,6 @@ export const CellWrapper: FunctionComponent = memo( rowHeightsOptions, rowHeightUtils, rowManager, - shouldUpdateLineHeight, ...rest }) => { const popoverContext = useContext(DataGridCellPopoverContext); @@ -156,7 +155,6 @@ export const CellWrapper: FunctionComponent = memo( width={leadingColumn.width} renderCellValue={rowCellRender} isExpandable={false} - shouldUpdateLineHeight={shouldUpdateLineHeight} {...rest} /> ); @@ -173,7 +171,6 @@ export const CellWrapper: FunctionComponent = memo( width={trailingColumn.width} renderCellValue={rowCellRender} isExpandable={false} - shouldUpdateLineHeight={shouldUpdateLineHeight} {...rest} /> ); @@ -197,7 +194,6 @@ export const CellWrapper: FunctionComponent = memo( renderCellPopover={renderCellPopover} interactiveCellId={interactiveCellId} isExpandable={isExpandable} - shouldUpdateLineHeight={shouldUpdateLineHeight} {...rest} /> ); diff --git a/packages/eui/src/components/datagrid/body/data_grid_body_virtualized.tsx b/packages/eui/src/components/datagrid/body/data_grid_body_virtualized.tsx index 90bd80512d0..aeaee32047c 100644 --- a/packages/eui/src/components/datagrid/body/data_grid_body_virtualized.tsx +++ b/packages/eui/src/components/datagrid/body/data_grid_body_virtualized.tsx @@ -42,13 +42,11 @@ import { } from '../utils/grid_height_width'; import { useDefaultColumnWidth, useColumnWidths } from '../utils/col_widths'; import { useRowHeightUtils, useDefaultRowHeight } from '../utils/row_heights'; -import { useShouldUpdateCellLineHeight } from '../utils/cell_heights'; import { useScrollBars, useScroll } from '../utils/scrolling'; import { IS_JEST_ENVIRONMENT } from '../../../utils'; export const Cell: FunctionComponent = memo( ({ columnIndex, rowIndex, style, data }) => { - const { gridStyles, ...cellData } = data; const memoizedStyles = useDeepEqual(style); const cellStyles = useMemo(() => { const { headerRowHeight } = data; @@ -58,15 +56,12 @@ export const Cell: FunctionComponent = memo( }; }, [memoizedStyles, data]); - const shouldUpdateLineHeight = useShouldUpdateCellLineHeight(gridStyles); - return ( ); } @@ -339,7 +334,6 @@ export const EuiDataGridBodyVirtualized: FunctionComponent rowManager, pagination, headerRowHeight, - gridStyles, }; }, [ schemaDetectors, @@ -360,7 +354,6 @@ export const EuiDataGridBodyVirtualized: FunctionComponent rowManager, pagination, headerRowHeight, - gridStyles, ]); const rowWrapperContextValue = useMemo(() => { diff --git a/packages/eui/src/components/datagrid/data_grid_types.ts b/packages/eui/src/components/datagrid/data_grid_types.ts index 4eef206472d..c7f72782035 100644 --- a/packages/eui/src/components/datagrid/data_grid_types.ts +++ b/packages/eui/src/components/datagrid/data_grid_types.ts @@ -640,7 +640,6 @@ export interface EuiDataGridCellProps { rowHeightUtils?: RowHeightUtilsType; rowManager?: EuiDataGridRowManager; pagination?: Required; - shouldUpdateLineHeight?: boolean; } export interface EuiDataGridCellState { diff --git a/packages/eui/src/components/datagrid/utils/cell_heights.ts b/packages/eui/src/components/datagrid/utils/cell_heights.ts deleted file mode 100644 index 3616bf7b8a6..00000000000 --- a/packages/eui/src/components/datagrid/utils/cell_heights.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -import { useEffect, useRef, useState } from 'react'; - -import { EuiDataGridBodyProps } from '../data_grid_types'; - -export const useShouldUpdateCellLineHeight = ( - gridStyles: EuiDataGridBodyProps['gridStyles'] -) => { - const _gridStyles = useRef(gridStyles); - const [shouldUpdateLineHeight, setShouldUpdateLineHeight] = useState(false); - - useEffect(() => { - if ( - gridStyles && - (_gridStyles.current?.fontSize || _gridStyles.current?.cellPadding) - ) { - const hasNewFontSize = _gridStyles.current?.fontSize - ? _gridStyles.current?.fontSize !== gridStyles?.fontSize - : false; - const hasNewCellPadding = _gridStyles.current?.cellPadding - ? _gridStyles.current?.cellPadding !== gridStyles?.cellPadding - : false; - - setShouldUpdateLineHeight(hasNewFontSize || hasNewCellPadding); - - _gridStyles.current = gridStyles; - } - }, [gridStyles]); - - return shouldUpdateLineHeight; -};