From 69b3a9d9488a23420a30ea5f30eccca9b37008cd Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Fri, 29 May 2026 18:39:37 -0700 Subject: [PATCH] fix: cancel floating context menu frame (#3409) --- .../FloatingTerminalIconContextMenu.tsx | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/components/floating-terminal/FloatingTerminalIconContextMenu.tsx b/src/renderer/src/components/floating-terminal/FloatingTerminalIconContextMenu.tsx index d1918695f51..3384ef9ef7a 100644 --- a/src/renderer/src/components/floating-terminal/FloatingTerminalIconContextMenu.tsx +++ b/src/renderer/src/components/floating-terminal/FloatingTerminalIconContextMenu.tsx @@ -1,4 +1,4 @@ -import { useMemo, useState } from 'react' +import { useEffect, useMemo, useRef, useState } from 'react' import { EyeOff, PanelBottom, PanelTop } from 'lucide-react' import { DropdownMenu, @@ -26,6 +26,17 @@ export function FloatingTerminalIconContextMenu({ const updateSettings = useAppStore((s) => s.updateSettings) const [open, setOpen] = useState(false) const [menuPoint, setMenuPoint] = useState({ x: 0, y: 0 }) + const reopenFrameRef = useRef(null) + + useEffect( + () => () => { + if (reopenFrameRef.current !== null) { + window.cancelAnimationFrame(reopenFrameRef.current) + reopenFrameRef.current = null + } + }, + [] + ) const moveAction = useMemo(() => { if (currentLocation === 'floating-button') { @@ -55,7 +66,13 @@ export function FloatingTerminalIconContextMenu({ event.stopPropagation() setMenuPoint({ x: event.clientX, y: event.clientY }) setOpen(false) - window.requestAnimationFrame(() => setOpen(true)) + if (reopenFrameRef.current !== null) { + window.cancelAnimationFrame(reopenFrameRef.current) + } + reopenFrameRef.current = window.requestAnimationFrame(() => { + reopenFrameRef.current = null + setOpen(true) + }) }} onContextMenu={(event) => { event.preventDefault()