mirror of
https://fastgit.cc/https://github.com/anomalyco/opencode
synced 2026-04-20 21:00:29 +08:00
fix: prevent tooltip reopen on trigger click (#22571)
This commit is contained in:
@@ -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" /> */}
|
||||
|
||||
Reference in New Issue
Block a user