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] Deprecate the closePopover callback passed to cellActions in favor of closeCellPopover ref API #5734

Merged
merged 3 commits into from
Apr 5, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,18 @@ export const DataGridCellsExample = {
your cell actions to switch correctly between button icons and
buttons.
</p>
<p>
To close a cell&apos;s expansion popover upon clicking an action,
use the{' '}
<Link to="/tabular-content/data-grid-advanced#ref-methods">
closeCellPopover
</Link>{' '}
API available via the <EuiCode>ref</EuiCode> prop.
</p>
<p>
In the below example, the email and city columns provide 1{' '}
<EuiCode>cellAction</EuiCode> each, while the country column
provides 2 <EuiCode>cellAction</EuiCode>s.
<br />
The email column cell action closes the popover if it&apos;s
expanded through the <EuiCode>closePopover</EuiCode> prop.
</p>
</Fragment>
),
Expand Down
2 changes: 0 additions & 2 deletions src/components/datagrid/body/data_grid_cell.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ describe('EuiDataGridCell', () => {
});
(getCellActions().prop('onExpandClick') as Function)();
expect(mockPopoverContext.closeCellPopover).toHaveBeenCalledTimes(1);
(getCellActions().prop('closePopover') as Function)();
expect(mockPopoverContext.closeCellPopover).toHaveBeenCalledTimes(2);
});

describe('shouldComponentUpdate', () => {
Expand Down
1 change: 0 additions & 1 deletion src/components/datagrid/body/data_grid_cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,6 @@ export class EuiDataGridCell extends Component<
rowIndex={rowIndex}
colIndex={colIndex}
column={column}
closePopover={closeCellPopover}
onExpandClick={() => {
if (popoverIsOpen) {
closeCellPopover();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const MockAction: EuiDataGridColumnCellAction = ({ Component }) => (

describe('EuiDataGridCellActions', () => {
const requiredProps = {
closePopover: jest.fn(),
onExpandClick: jest.fn(),
rowIndex: 0,
colIndex: 0,
Expand Down Expand Up @@ -93,7 +92,6 @@ describe('EuiDataGridCellActions', () => {
>
<MockAction
Component={[Function]}
closePopover={[MockFunction]}
colIndex={0}
columnId="someId"
isExpanded={false}
Expand Down
5 changes: 1 addition & 4 deletions src/components/datagrid/body/data_grid_cell_actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ import { EuiFlexGroup, EuiFlexItem } from '../../flex';
import { EuiPopoverFooter } from '../../popover';

export const EuiDataGridCellActions = ({
closePopover,
onExpandClick,
column,
rowIndex,
colIndex,
}: {
closePopover: () => void;
onExpandClick: () => void;
column?: EuiDataGridColumn;
rowIndex: number;
Expand Down Expand Up @@ -88,12 +86,11 @@ export const EuiDataGridCellActions = ({
columnId={column.id}
Component={ButtonComponent}
isExpanded={false}
closePopover={closePopover}
/>
);
}
);
}, [column, colIndex, rowIndex, closePopover]);
}, [column, colIndex, rowIndex]);

return (
<div className="euiDataGridRowCell__expandActions">
Expand Down
5 changes: 0 additions & 5 deletions src/components/datagrid/data_grid_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -637,11 +637,6 @@ export interface EuiDataGridColumnCellActionProps {
* Determines whether the cell's action is displayed expanded (in the Popover)
*/
isExpanded: boolean;
/**
* Closes the popover if a cell is expanded.
* The prop is provided for an expanded cell only.
*/
closePopover?: () => void;
}

export interface EuiDataGridColumnVisibility {
Expand Down
3 changes: 3 additions & 0 deletions upcoming_changelogs/5734.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**Breaking changes**

- Removed the `closePopover()` callback passed to `EuiDataGrid`'s `cellActions` render functions. Use `closeCellPopover()` passed by `EuiDataGrid`'s `ref` prop instead.