From bbbd8c2b1671426688c96edc99827ee88535f397 Mon Sep 17 00:00:00 2001 From: Pavel Kovyrshin Date: Thu, 12 Sep 2024 15:16:50 +0300 Subject: [PATCH] fix(SharePopover): restore focus on close --- src/components/SharePopover/SharePopover.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/SharePopover/SharePopover.tsx b/src/components/SharePopover/SharePopover.tsx index 4883486f..79970a84 100644 --- a/src/components/SharePopover/SharePopover.tsx +++ b/src/components/SharePopover/SharePopover.tsx @@ -108,6 +108,7 @@ export const SharePopover = (props: SharePopoverProps) => { buttonAriaLabel, } = props; const [isOpen, setIsOpen] = React.useState(false); + const buttonRef = React.useRef(null); const tooltipId = useUniqId(); const content = React.useMemo( @@ -174,6 +175,7 @@ export const SharePopover = (props: SharePopoverProps) => { onOpenChange={setIsOpen} focusTrap={!shouldOpenByHover} autoFocus={!shouldOpenByHover} + restoreFocusRef={shouldOpenByHover ? undefined : buttonRef} > {({onClick: onClickInner}) => (