Skip to content

Commit

Permalink
Toggle action and service icon menus (#87220)
Browse files Browse the repository at this point in the history
Make it so clicking the icon menu or action menu while the popover is open closes the popover. This also fixes the issue where the action menu would not close at all.

Rename the `onOpen` prop to `onClick` to match what it does.

Fixes #87161. Fixes #87131.
  • Loading branch information
smith authored Jan 5, 2021
1 parent 8ac632b commit 42ba5a8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { px } from '../../../../style/variables';
interface IconPopoverProps {
title: string;
children: React.ReactChild;
onOpen: () => void;
onClick: () => void;
onClose: () => void;
detailsFetchStatus: FETCH_STATUS;
isOpen: boolean;
Expand All @@ -27,7 +27,7 @@ export function IconPopover({
icon,
title,
children,
onOpen,
onClick,
onClose,
detailsFetchStatus,
isOpen,
Expand All @@ -44,7 +44,7 @@ export function IconPopover({
anchorPosition="downCenter"
ownFocus={false}
button={
<EuiButtonEmpty onClick={onOpen} data-test-subj={`popover_${title}`}>
<EuiButtonEmpty onClick={onClick} data-test-subj={`popover_${title}`}>
<EuiIcon type={icon} size="l" color="black" />
</EuiButtonEmpty>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,10 @@ export function ServiceIcons({ serviceName }: Props) {
icon={item.icon}
detailsFetchStatus={detailsFetchStatus}
title={item.title}
onOpen={() => {
setSelectedIconPopover(item.key);
onClick={() => {
setSelectedIconPopover((prevSelectedIconPopover) =>
item.key === prevSelectedIconPopover ? null : item.key
);
}}
onClose={() => {
setSelectedIconPopover(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,13 @@ export function TransactionActionMenu({ transaction }: Props) {
isOpen={isActionPopoverOpen}
anchorPosition="downRight"
button={
<ActionMenuButton onClick={() => setIsActionPopoverOpen(true)} />
<ActionMenuButton
onClick={() =>
setIsActionPopoverOpen(
(prevIsActionPopoverOpen) => !prevIsActionPopoverOpen
)
}
/>
}
>
<div>
Expand Down

0 comments on commit 42ba5a8

Please sign in to comment.