From 0ab21bbc204f5e26dccfaea865331d3f984af8ed Mon Sep 17 00:00:00 2001 From: Kirill Dyachkovskiy <81510334+KirillDyachkovskiy@users.noreply.github.com> Date: Tue, 23 Apr 2024 17:03:19 +0300 Subject: [PATCH] feat(Table): close table actions popup after click (#1546) --- .../Table/hoc/withTableActions/withTableActions.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/Table/hoc/withTableActions/withTableActions.tsx b/src/components/Table/hoc/withTableActions/withTableActions.tsx index 8a988ce363..cdb2f3145b 100644 --- a/src/components/Table/hoc/withTableActions/withTableActions.tsx +++ b/src/components/Table/hoc/withTableActions/withTableActions.tsx @@ -4,6 +4,7 @@ import {Ellipsis} from '@gravity-ui/icons'; import _memoize from 'lodash/memoize'; import {useUniqId} from '../../../../hooks'; +import {useBoolean} from '../../../../hooks/private'; import type {PopperPlacement} from '../../../../hooks/private'; import {Button} from '../../../Button'; import {Icon} from '../../../Icon'; @@ -112,7 +113,7 @@ const DefaultRowActions = ({ rowActionsSize, isRowDisabled, }: DefaultRowActionsProps) => { - const [open, setOpen] = React.useState(false); + const [isPopupOpen, , closePopup, togglePopup] = useBoolean(false); const anchorRef = React.useRef(null); const rowId = useUniqId(); @@ -137,6 +138,8 @@ const DefaultRowActions = ({ onClick={(event) => { event.stopPropagation(); handler(item, index, event); + + closePopup(); }} iconStart={icon} className={menuItemCn} @@ -158,10 +161,10 @@ const DefaultRowActions = ({ return (
setOpen(false)} + onOutsideClick={closePopup} id={rowId} > @@ -171,13 +174,13 @@ const DefaultRowActions = ({