From 8d89c3417bcfb6bb29793a640a37686957e82692 Mon Sep 17 00:00:00 2001
From: Brendan Allan <brendonovich@outlook.com>
Date: Wed, 15 Apr 2026 14:03:29 +0800
Subject: fix: prevent tooltip reopen on trigger click (#22571)

---
 packages/ui/src/components/tooltip.tsx | 12 ++++++++++++
 1 file changed, 12 insertions(+)

(limited to 'packages/ui/src/components/tooltip.tsx')

diff --git a/packages/ui/src/components/tooltip.tsx b/packages/ui/src/components/tooltip.tsx
index ada597d0f..4366651d2 100644
--- a/packages/ui/src/components/tooltip.tsx
+++ b/packages/ui/src/components/tooltip.tsx
@@ -99,6 +99,8 @@ export function Tooltip(props: TooltipProps) {
     onCleanup(() => obs.disconnect())
   })
 
+  let justClickedTrigger = false
+
   return (
     <Switch>
       <Match when={local.inactive}>{local.children}</Match>
@@ -112,6 +114,10 @@ export function Tooltip(props: TooltipProps) {
           onOpenChange={(open) => {
             if (local.forceOpen) return
             if (state.block && open) return
+            if (justClickedTrigger) {
+              justClickedTrigger = false
+              return
+            }
             setState("open", open)
           }}
         >
@@ -137,6 +143,12 @@ export function Tooltip(props: TooltipProps) {
               data-force-open={local.forceOpen}
               class={local.contentClass}
               style={local.contentStyle}
+              onPointerDownOutside={(e) => {
+                if (ref === e.target || (e.target instanceof Node && ref?.contains(e.target))) {
+                  justClickedTrigger = true
+                }
+                e.preventDefault()
+              }}
             >
               {local.value}
               {/* <KobalteTooltip.Arrow data-slot="tooltip-arrow" /> */}
-- 
cgit v1.2.3

