From 2c17a06bd3bb52f730a8dc810bcfc22a3a9c163c Mon Sep 17 00:00:00 2001 From: "Mr.Dr.Professor Patrick" Date: Fri, 3 Nov 2023 11:34:52 +0100 Subject: [PATCH] feat(Popover): prevent closing by click in case of using openOnHover property (#1085) --- src/components/Popover/Popover.tsx | 1 + src/components/Popover/components/Trigger/Trigger.tsx | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/Popover/Popover.tsx b/src/components/Popover/Popover.tsx index 54cdce470e..7b8e9e15cc 100644 --- a/src/components/Popover/Popover.tsx +++ b/src/components/Popover/Popover.tsx @@ -207,6 +207,7 @@ export const Popover = React.forwardRef { const handleClick = async (event: React.MouseEvent) => { - if (disabled) { + // Ignores click that should close tooltip in case of {openOnHover: true} + // to prevent situation when user could close tooltip accidentally + const shouldPreventClosingByClick = open && openOnHover; + + if (disabled || shouldPreventClosingByClick) { return; }