mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 00:02:31 +00:00
fix: cancel floating panel focus frame (#3455)
This commit is contained in:
@@ -139,6 +139,8 @@ export function FloatingTerminalPanel({
|
||||
const pendingEditorCloseQueueRef = useRef<string[]>([])
|
||||
const saveDialogFileIdRef = useRef<string | null>(null)
|
||||
const panelRef = useRef<HTMLDivElement>(null)
|
||||
const shortcutFocusFrameRef = useRef<number | null>(null)
|
||||
const shortcutFocusTimeoutRef = useRef<number | null>(null)
|
||||
const dragRef = useRef<{
|
||||
pointerId: number
|
||||
startX: number
|
||||
@@ -690,17 +692,35 @@ export function FloatingTerminalPanel({
|
||||
panelRef.current?.focus({ preventScroll: true })
|
||||
}, [])
|
||||
|
||||
const cancelShortcutFocusFrame = useCallback((): void => {
|
||||
if (shortcutFocusFrameRef.current !== null) {
|
||||
cancelAnimationFrame(shortcutFocusFrameRef.current)
|
||||
shortcutFocusFrameRef.current = null
|
||||
}
|
||||
if (shortcutFocusTimeoutRef.current !== null) {
|
||||
window.clearTimeout(shortcutFocusTimeoutRef.current)
|
||||
shortcutFocusTimeoutRef.current = null
|
||||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => cancelShortcutFocusFrame, [cancelShortcutFocusFrame])
|
||||
|
||||
const focusPanelForShortcutsAfterClose = useCallback(() => {
|
||||
if (typeof window === 'undefined') {
|
||||
return
|
||||
}
|
||||
const focusPanel = (): void => focusPanelForShortcuts(false)
|
||||
cancelShortcutFocusFrame()
|
||||
const focusPanel = (): void => {
|
||||
shortcutFocusFrameRef.current = null
|
||||
shortcutFocusTimeoutRef.current = null
|
||||
focusPanelForShortcuts(false)
|
||||
}
|
||||
if (typeof window.requestAnimationFrame === 'function') {
|
||||
window.requestAnimationFrame(focusPanel)
|
||||
shortcutFocusFrameRef.current = window.requestAnimationFrame(focusPanel)
|
||||
return
|
||||
}
|
||||
globalThis.setTimeout(focusPanel, 0)
|
||||
}, [focusPanelForShortcuts])
|
||||
shortcutFocusTimeoutRef.current = window.setTimeout(focusPanel, 0)
|
||||
}, [cancelShortcutFocusFrame, focusPanelForShortcuts])
|
||||
|
||||
const setFloatingTerminalInputFocused = useCallback((target: EventTarget | null): void => {
|
||||
window.api.ui.setFloatingTerminalInputFocused(isFloatingWorkspaceTerminalInputTarget(target))
|
||||
|
||||
Reference in New Issue
Block a user