Skip to content

Commit

Permalink
[PR feedback] Ignore edge case of openCellPopover being called on a…
Browse files Browse the repository at this point in the history
…n `isExpandable: false` cell
  • Loading branch information
cee-chen committed Jan 26, 2022
1 parent 75cf1ad commit f9ed152
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
3 changes: 1 addition & 2 deletions src/components/datagrid/body/data_grid_cell.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<EuiDataGridCell {...props} isExpandable={false} />
);
expect((component.instance() as any).isPopoverOpen()).toEqual(false);
expect(mockPopoverContext.closeCellPopover).toHaveBeenCalled();
});
});

Expand Down
15 changes: 3 additions & 12 deletions src/components/datagrid/body/data_grid_cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down

0 comments on commit f9ed152

Please sign in to comment.