mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 00:02:31 +00:00
fix: cancel floating context menu frame (#3409)
This commit is contained in:
@@ -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<number | null>(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()
|
||||
|
||||
Reference in New Issue
Block a user