diff --git a/src/components/PopoverProvider/index.js b/src/components/PopoverProvider/index.js index e12e7a96e549..efa230d920d5 100644 --- a/src/components/PopoverProvider/index.js +++ b/src/components/PopoverProvider/index.js @@ -48,7 +48,10 @@ function PopoverContextProvider(props) { }, [closePopover]); React.useEffect(() => { - const listener = () => { + const listener = (e) => { + if (!activePopoverRef.current || !activePopoverRef.current.ref || !activePopoverRef.current.ref.current || activePopoverRef.current.ref.current.contains(e.target)) { + return; + } closePopover(); }; document.addEventListener('contextmenu', listener); diff --git a/src/components/PopoverWithoutOverlay/index.js b/src/components/PopoverWithoutOverlay/index.js index d42f735b19a8..778f65349969 100644 --- a/src/components/PopoverWithoutOverlay/index.js +++ b/src/components/PopoverWithoutOverlay/index.js @@ -35,6 +35,7 @@ function Popover(props) { } else { props.onModalHide(); close(props.anchorRef); + Modal.onModalDidClose(); } Modal.willAlertModalBecomeVisible(props.isVisible); Modal.setCloseModal(props.isVisible ? () => props.onClose(props.anchorRef) : null);