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

[Data Grid] Added closePopover action to EuiDataGridColumnCellActionProps #4346

Merged
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -2,6 +2,7 @@

- Adjusted the shadow in `EuiComment` ([#4321](https://github.com/elastic/eui/pull/4321))
- Added `success` and `warning` colors to `EuiButtonEmpty` ([#4325](https://github.com/elastic/eui/pull/4325))
- Added `closePopover` prop to `EuiDataGridColumnCellActionProps` ([#4346](https://github.com/elastic/eui/pull/4346))
- Added `disabled` and `loading` `status` to `EuiStep` ([#4338](https://github.com/elastic/eui/pull/4338))

**Bug fixes**
Expand Down
13 changes: 6 additions & 7 deletions src-docs/src/views/datagrid/column_cell_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@ const columns = [
id: 'email',
isSortable: true,
cellActions: [
({ rowIndex, columnId, Component }) => {
const row = ++rowIndex;
({ Component, closePopover }) => {
return (
<Component
onClick={() =>
alert(`Love sent from row ${row}, column "${columnId}"`)
}
onClick={() => {
closePopover?.();
}}
iconType="heart"
aria-label={`Send love to ${row}, column "${columnId}" `}>
Send love
aria-label="Close the popover if expanded">
Close the popover
</Component>
);
},
Expand Down
10 changes: 7 additions & 3 deletions src-docs/src/views/datagrid/datagrid_styling_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,13 @@ export const DataGridStylingExample = {
<p>
Below, the email and city columns provide 1{' '}
<EuiCode>cellAction</EuiCode> each, while the country column
provides 2 <EuiCode>cellAction</EuiCode>s. The city column shows
another action with different alert when it&apos;s clicked in the
popover.
provides 2 <EuiCode>cellAction</EuiCode>s.
<br />
The email column cell action closes the popover if it&apos;s
expanded through the optional <EuiCode>closePopover</EuiCode> prop.
<br />
The city column shows another action with different alert when
it&apos;s clicked in the popover.
</p>
</Fragment>
),
Expand Down
1 change: 1 addition & 0 deletions src/components/datagrid/data_grid_cell_popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export function EuiDataGridCellPopover({
<EuiButtonEmpty {...props} size="s" />
)}
isExpanded={true}
closePopover={closePopover}
/>
</EuiFlexItem>
);
Expand Down
5 changes: 5 additions & 0 deletions src/components/datagrid/data_grid_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ 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