Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EuiDataGrid] Fix open cell popovers causing auto height rows to bug out #5618

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Fixed `EuiDataGrid` to correctly remove the cell expansion action button when a column sets both `cellActions` and `isExpandable` to false ([#5592](https://github.com/elastic/eui/pull/5592))
- Fixed `EuiDataGrid` re-playing the cell actions animation when hovering over an already-focused cell ([#5592](https://github.com/elastic/eui/pull/5592))
- Fixed `EuiDataGrid` auto row heights bugging out when cell popovers are opened ([#5618](https://github.com/elastic/eui/pull/5618))

**Breaking changes**

Expand Down
14 changes: 14 additions & 0 deletions src/components/datagrid/body/data_grid_cell.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,20 @@ describe('EuiDataGridCell', () => {
);
expect(popoverContent).toMatchSnapshot();
});

it('does not recalculate row auto height when the cell popover opens', () => {
const component = mount(
<EuiDataGridCell
{...requiredProps}
rowHeightsOptions={{ defaultHeight: 'auto' }}
/>
);
component.setProps({
popoverContext: { ...mockPopoverContext, popoverIsOpen: true },
});
expect(mockRowHeightUtils.isAutoHeight).not.toHaveBeenCalled();
expect(mockRowHeightUtils.setRowHeight).not.toHaveBeenCalled();
});
});

describe('componentDidMount', () => {
Expand Down
32 changes: 14 additions & 18 deletions src/components/datagrid/body/data_grid_cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,11 @@ export class EuiDataGridCell extends Component<
}

componentDidUpdate(prevProps: EuiDataGridCellProps) {
this.recalculateAutoHeight();
// Avoid recalculating auto height when the popover opens -
// the inserted EuiWrappingPopover DOM creates false miscalculations
if (!this.props.popoverContext.popoverIsOpen) {
this.recalculateAutoHeight();
}

if (
this.props.rowHeightsOptions?.defaultHeight !==
Expand Down Expand Up @@ -627,12 +631,12 @@ export class EuiDataGridCell extends Component<
);

if (hasCellActions) {
if (showCellActions) {
innerContent = (
<div className={anchorClass} ref={this.popoverAnchorRef}>
<div className={expandClass}>
<EuiDataGridCellContent {...cellContentProps} />
</div>
innerContent = (
<div className={anchorClass} ref={this.popoverAnchorRef}>
<div className={expandClass}>
<EuiDataGridCellContent {...cellContentProps} />
</div>
{showCellActions && (
<EuiDataGridCellActions
rowIndex={rowIndex}
colIndex={colIndex}
Expand All @@ -647,17 +651,9 @@ export class EuiDataGridCell extends Component<
}
}}
/>
</div>
);
} else {
innerContent = (
<div className={anchorClass} ref={this.popoverAnchorRef}>
<div className={expandClass}>
<EuiDataGridCellContent {...cellContentProps} />
</div>
</div>
);
}
)}
</div>
);
}

const content = (
Expand Down