From 74c30e8313ea889598c55f7e1dd04b568e31847c Mon Sep 17 00:00:00 2001 From: kmcfaul <45077788+kmcfaul@users.noreply.github.com> Date: Wed, 10 Jan 2024 11:42:12 -0500 Subject: [PATCH] fix(Popover): doc click event (#9952) --- 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) {