Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion resources/js/components/ui/tooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Slot } from "@radix-ui/react-slot"
import * as TooltipPrimitive from "@radix-ui/react-tooltip"
import * as React from "react"
import { flushSync } from "react-dom"

import { cn } from "@/lib/utils"

Expand Down Expand Up @@ -47,7 +48,9 @@ function Tooltip({
isArmed,
arm: (byFocus) => {
takesFocus.current = byFocus
setHasArmed(true)
// At once: React waits to render after a pointer enters, and a click landing meanwhile would press the trigger
// before it is mounted again and be released on the new one, which loses it.
flushSync(() => setHasArmed(true))
},
consumeFocus: () => {
const takes = takesFocus.current
Expand Down