Skip to content

Commit

Permalink
[cleanup] Remove more now-unnecessary height-based CSS/logic
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen committed Nov 15, 2023
1 parent 8f9c4a0 commit c068806
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 26 deletions.
9 changes: 3 additions & 6 deletions src/components/datagrid/body/data_grid_cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ const EuiDataGridCellContent: FunctionComponent<
isFocused: boolean;
ariaRowIndex: number;
rowHeight?: EuiDataGridRowHeightOption;
cellHeightType: string;
cellActions?: ReactNode;
}
> = memo(
Expand All @@ -69,14 +68,16 @@ const EuiDataGridCellContent: FunctionComponent<
rowHeightUtils,
isControlColumn,
isFocused,
cellHeightType,
cellActions,
...rest
}) => {
// React is more permissible than the TS types indicate
const CellElement =
renderCellValue as JSXElementConstructor<EuiDataGridCellValueElementProps>;

const cellHeightType =
rowHeightUtils?.getHeightType(rowHeight) || 'default';

const classes = classNames(
'euiDataGridRowCell__content',
`euiDataGridRowCell__content--${cellHeightType}Height`,
Expand Down Expand Up @@ -711,15 +712,12 @@ export class EuiDataGridCell extends Component<
rowIndex,
rowHeightsOptions
);
const cellHeightType =
rowHeightUtils?.getHeightType(rowHeight) || 'default';

const cellContentProps = {
...rest,
setCellProps: this.setCellProps,
column,
columnType,
cellHeightType,
isExpandable,
isExpanded: popoverIsOpen,
isDetails: false,
Expand All @@ -739,7 +737,6 @@ export class EuiDataGridCell extends Component<
rowIndex={rowIndex}
colIndex={colIndex}
column={column}
cellHeightType={cellHeightType}
onExpandClick={() => {
if (popoverIsOpen) {
closeCellPopover();
Expand Down
12 changes: 0 additions & 12 deletions src/components/datagrid/body/data_grid_cell_actions.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import React from 'react';
import { shallow } from 'enzyme';
import { render } from '../../../test/rtl';

import { EuiDataGridColumnCellAction } from '../data_grid_types';
import {
Expand Down Expand Up @@ -113,17 +112,6 @@ describe('EuiDataGridCellActions', () => {
`);
});

it('renders with overlay positioning for non default height cells', () => {
const { container } = render(
<EuiDataGridCellActions {...requiredProps} cellHeightType="auto" />
);

// TODO: Switch to `.toHaveStyle({ position: 'absolute' })` once on Emotion
expect(container.firstChild).toHaveClass(
'euiDataGridRowCell__actions--overlay'
);
});

describe('visible cell actions limit', () => {
it('by default, does not render more than the first two primary cell actions', () => {
const component = shallow(
Expand Down
13 changes: 5 additions & 8 deletions src/components/datagrid/body/data_grid_cell_actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,17 @@ import { EuiButtonIcon, EuiButtonIconProps } from '../../button/button_icon';
import { EuiButtonEmpty, EuiButtonEmptyProps } from '../../button/button_empty';
import { EuiFlexGroup, EuiFlexItem } from '../../flex';
import { EuiPopoverFooter } from '../../popover';
import classNames from 'classnames';

export const EuiDataGridCellActions = ({
onExpandClick,
column,
rowIndex,
colIndex,
cellHeightType,
}: {
onExpandClick: () => void;
column?: EuiDataGridColumn;
rowIndex: number;
colIndex: number;
cellHeightType: string;
}) => {
// Note: The cell expand button/expansion popover is *always* rendered if
// column.cellActions is present (regardless of column.isExpandable).
Expand Down Expand Up @@ -96,11 +93,11 @@ export const EuiDataGridCellActions = ({
);
}, [column, colIndex, rowIndex]);

const classes = classNames('euiDataGridRowCell__actions', {
'euiDataGridRowCell__actions--overlay': cellHeightType !== 'default',
});

return <div className={classes}>{[...additionalButtons, expandButton]}</div>;
return (
<div className="euiDataGridRowCell__actions">
{[...additionalButtons, expandButton]}
</div>
);
};

export const EuiDataGridCellPopoverActions = ({
Expand Down

0 comments on commit c068806

Please sign in to comment.