Toggle action and service icon menus (#87220)

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.
This commit is contained in:
Nathan L Smith 2021-01-04 18:40:10 -06:00 committed by GitHub
parent 8ac632b068
commit 42ba5a8e9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 6 deletions

View file

@ -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;
@ -27,7 +27,7 @@ export function IconPopover({
icon,
title,
children,
onOpen,
onClick,
onClose,
detailsFetchStatus,
isOpen,
@ -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>
}

View file

@ -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);

View file

@ -63,7 +63,13 @@ export function TransactionActionMenu({ transaction }: Props) {
isOpen={isActionPopoverOpen}
anchorPosition="downRight"
button={
<ActionMenuButton onClick={() => setIsActionPopoverOpen(true)} />
<ActionMenuButton
onClick={() =>
setIsActionPopoverOpen(
(prevIsActionPopoverOpen) => !prevIsActionPopoverOpen
)
}
/>
}
>
<div>