From b22a29b9e684c1b1fc97b8ad97ef3116368ad5cb Mon Sep 17 00:00:00 2001 From: Katie McFaul Date: Tue, 9 Jan 2024 14:56:25 -0500 Subject: [PATCH] fix(Popover): doc click event --- packages/react-core/src/components/Popover/Popover.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/react-core/src/components/Popover/Popover.tsx b/packages/react-core/src/components/Popover/Popover.tsx index 3b16d0446f8..c0225e01c3c 100644 --- a/packages/react-core/src/components/Popover/Popover.tsx +++ b/packages/react-core/src/components/Popover/Popover.tsx @@ -334,10 +334,10 @@ export const Popover: React.FunctionComponent = ({ }; const onDocumentClick = (event: MouseEvent, triggerElement: HTMLElement, popperElement: HTMLElement) => { if (hideOnOutsideClick && visible) { - // check if we clicked within the popper, if so don't do anything - const isChild = popperElement && popperElement.contains(event.target as Node); - if (isChild) { - // clicked within the popper + const isFromChild = popperElement && popperElement.contains(event.target as Node); + const isFromTrigger = triggerElement && triggerElement.contains(event.target as Node); + if (isFromChild || isFromTrigger) { + // if clicked within the popper or on the trigger, ignore this event return; } if (triggerManually) {