From f9ed15283b71b1f669c1791977716deb547b584d Mon Sep 17 00:00:00 2001 From: Constance Chen Date: Tue, 25 Jan 2022 16:24:47 -0800 Subject: [PATCH] [PR feedback] Ignore edge case of `openCellPopover` being called on an `isExpandable: false` cell --- .../datagrid/body/data_grid_cell.test.tsx | 3 +-- src/components/datagrid/body/data_grid_cell.tsx | 15 +++------------ 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/components/datagrid/body/data_grid_cell.test.tsx b/src/components/datagrid/body/data_grid_cell.test.tsx index 210fea22806..07e6bb5474c 100644 --- a/src/components/datagrid/body/data_grid_cell.test.tsx +++ b/src/components/datagrid/body/data_grid_cell.test.tsx @@ -380,12 +380,11 @@ describe('EuiDataGridCell', () => { expect((component.instance() as any).isPopoverOpen()).toEqual(false); }); - it('returns false if the cell is not expandable, and sets popover state to closed', () => { + it('returns false if the cell is not expandable', () => { const component = mount( ); expect((component.instance() as any).isPopoverOpen()).toEqual(false); - expect(mockPopoverContext.closeCellPopover).toHaveBeenCalled(); }); }); diff --git a/src/components/datagrid/body/data_grid_cell.tsx b/src/components/datagrid/body/data_grid_cell.tsx index 46954bd79e1..7413dfc58e8 100644 --- a/src/components/datagrid/body/data_grid_cell.tsx +++ b/src/components/datagrid/body/data_grid_cell.tsx @@ -423,21 +423,12 @@ export class EuiDataGridCell extends Component< const { isExpandable, popoverContext } = this.props; const { popoverIsOpen, cellLocation } = popoverContext; - if ( + return ( + isExpandable && popoverIsOpen && cellLocation.colIndex === this.props.colIndex && cellLocation.rowIndex === this.props.visibleRowIndex - ) { - if (isExpandable) { - return true; - } else { - // If `openCellPopover` was somehow called on this cell but it's not - // supposed to be expandable, we should do nothing and set popoverIsOpen - // state back to false - popoverContext.closeCellPopover(); - } - } - return false; + ); }; handleCellPopover = () => {