componentDidUpdate()

in packages/eui/src/components/datagrid/body/cell/data_grid_cell.tsx [300:352]


  componentDidUpdate(prevProps: EuiDataGridCellProps) {
    this.recalculateAutoHeight();

    if (
      this.props.rowHeightsOptions?.defaultHeight !==
        prevProps.rowHeightsOptions?.defaultHeight ||
      this.props.rowHeightsOptions?.rowHeights?.[this.props.rowIndex] !==
        prevProps.rowHeightsOptions?.rowHeights?.[prevProps.rowIndex] ||
      this.props.rowHeightsOptions?.lineHeight !==
        prevProps.rowHeightsOptions?.lineHeight ||
      this.props.gridStyles?.fontSize !== prevProps.gridStyles?.fontSize ||
      this.props.gridStyles?.cellPadding !== prevProps.gridStyles?.cellPadding
    ) {
      this.recalculateLineHeight();
    }

    if (
      (this.props.rowHeightUtils as RowHeightVirtualizationUtils)
        ?.compensateForLayoutShift &&
      this.props.rowHeightsOptions?.scrollAnchorRow &&
      this.props.colIndex === 0 && // once per row
      this.props.columnId === prevProps.columnId && // if this is still the same column
      this.props.rowIndex === prevProps.rowIndex && // if this is still the same row
      this.props.style?.top !== prevProps.style?.top // if the top position has changed
    ) {
      const previousTop = parseFloat(prevProps.style?.top as string);
      const currentTop = parseFloat(this.props.style?.top as string);

      // @ts-ignore We've already checked that this virtualization util is available above
      this.props.rowHeightUtils.compensateForLayoutShift(
        this.props.rowIndex,
        currentTop - previousTop,
        this.props.rowHeightsOptions?.scrollAnchorRow
      );
    }

    if (
      this.props.popoverContext.popoverIsOpen !==
        prevProps.popoverContext.popoverIsOpen ||
      this.props.popoverContext.cellLocation !==
        prevProps.popoverContext.cellLocation ||
      this.props.renderCellPopover !== prevProps.renderCellPopover
    ) {
      this.handleCellPopover();
    }

    if (
      this.props.columnId !== prevProps.columnId ||
      this.props.rowIndex !== prevProps.rowIndex
    ) {
      this.setCellProps({});
    }
  }