From d387880c148af8b21a8fcc8fcc72d3608f11db6c Mon Sep 17 00:00:00 2001 From: kirilldyachkovskiy Date: Tue, 23 Apr 2024 16:51:50 +0300 Subject: [PATCH 1/2] feat(Table): close table actions popup after click --- .../Table/hoc/withTableActions/withTableActions.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/Table/hoc/withTableActions/withTableActions.tsx b/src/components/Table/hoc/withTableActions/withTableActions.tsx index 8a988ce363..68353ed642 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 [open, , onClose, onToggle] = useBoolean(false); const anchorRef = React.useRef(null); const rowId = useUniqId(); @@ -137,6 +138,8 @@ const DefaultRowActions = ({ onClick={(event) => { event.stopPropagation(); handler(item, index, event); + + onClose(); }} iconStart={icon} className={menuItemCn} @@ -161,7 +164,7 @@ const DefaultRowActions = ({ open={open} anchorRef={anchorRef} placement={DEFAULT_PLACEMENT} - onOutsideClick={() => setOpen(false)} + onOutsideClick={onClose} id={rowId} > @@ -171,7 +174,7 @@ const DefaultRowActions = ({