mirror of
https://github.com/stablyai/orca
synced 2026-04-21 14:17:16 +00:00
menu fix
This commit is contained in:
parent
e8d487d90d
commit
2c89a02741
4 changed files with 39 additions and 3 deletions
|
|
@ -66,6 +66,7 @@
|
|||
"oxlint": "^1.56.0",
|
||||
"react": "^19.2.1",
|
||||
"react-dom": "^19.2.1",
|
||||
"react-grab": "link:/Users/nwparker/projects/react-grab/packages/react-grab",
|
||||
"tailwindcss": "^4.2.1",
|
||||
"typescript": "^5.9.3",
|
||||
"vite": "^7.2.6"
|
||||
|
|
|
|||
|
|
@ -123,6 +123,9 @@ importers:
|
|||
react-dom:
|
||||
specifier: ^19.2.1
|
||||
version: 19.2.4(react@19.2.4)
|
||||
react-grab:
|
||||
specifier: link:/Users/nwparker/projects/react-grab/packages/react-grab
|
||||
version: link:../react-grab/packages/react-grab
|
||||
tailwindcss:
|
||||
specifier: ^4.2.1
|
||||
version: 4.2.1
|
||||
|
|
|
|||
|
|
@ -397,6 +397,7 @@ export default function TerminalPane({
|
|||
isActiveRef.current = isActive
|
||||
const [terminalMenuOpen, setTerminalMenuOpen] = useState(false)
|
||||
const [terminalMenuPoint, setTerminalMenuPoint] = useState({ x: 0, y: 0 })
|
||||
const menuOpenedAtRef = useRef(0)
|
||||
const [expandedPaneId, setExpandedPaneId] = useState<number | null>(null)
|
||||
const [searchOpen, setSearchOpen] = useState(false)
|
||||
const setTabPaneExpanded = useAppStore((s) => s.setTabPaneExpanded)
|
||||
|
|
@ -538,7 +539,11 @@ export default function TerminalPane({
|
|||
}
|
||||
|
||||
useEffect(() => {
|
||||
const closeMenu = (): void => setTerminalMenuOpen(false)
|
||||
const closeMenu = (): void => {
|
||||
// Skip if we just opened (same frame / same event cycle)
|
||||
if (Date.now() - menuOpenedAtRef.current < 100) return
|
||||
setTerminalMenuOpen(false)
|
||||
}
|
||||
window.addEventListener(CLOSE_ALL_CONTEXT_MENUS_EVENT, closeMenu)
|
||||
return () => window.removeEventListener(CLOSE_ALL_CONTEXT_MENUS_EVENT, closeMenu)
|
||||
}, [])
|
||||
|
|
@ -1203,6 +1208,7 @@ export default function TerminalPane({
|
|||
style={terminalContainerStyle}
|
||||
onContextMenuCapture={(event) => {
|
||||
event.preventDefault()
|
||||
menuOpenedAtRef.current = Date.now()
|
||||
window.dispatchEvent(new Event(CLOSE_ALL_CONTEXT_MENUS_EVENT))
|
||||
|
||||
const manager = managerRef.current
|
||||
|
|
@ -1234,7 +1240,14 @@ export default function TerminalPane({
|
|||
/>,
|
||||
activePaneContainer
|
||||
)}
|
||||
<DropdownMenu open={terminalMenuOpen} onOpenChange={setTerminalMenuOpen} modal={false}>
|
||||
<DropdownMenu
|
||||
open={terminalMenuOpen}
|
||||
onOpenChange={(open) => {
|
||||
if (!open && Date.now() - menuOpenedAtRef.current < 100) return
|
||||
setTerminalMenuOpen(open)
|
||||
}}
|
||||
modal={false}
|
||||
>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<button
|
||||
aria-hidden
|
||||
|
|
@ -1243,7 +1256,21 @@ export default function TerminalPane({
|
|||
style={{ left: terminalMenuPoint.x, top: terminalMenuPoint.y }}
|
||||
/>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent className="w-56" sideOffset={0} align="start">
|
||||
<DropdownMenuContent
|
||||
className="w-56"
|
||||
sideOffset={0}
|
||||
align="start"
|
||||
onCloseAutoFocus={(e) => {
|
||||
// Prevent Radix from moving focus back to the hidden trigger;
|
||||
// let xterm keep focus naturally.
|
||||
e.preventDefault()
|
||||
}}
|
||||
onFocusOutside={(e) => {
|
||||
// xterm reclaims focus after the contextmenu event; don't let
|
||||
// Radix treat that as a dismiss signal.
|
||||
e.preventDefault()
|
||||
}}
|
||||
>
|
||||
<DropdownMenuItem onSelect={() => void handleCopy()}>
|
||||
<Copy />
|
||||
Copy
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ import { StrictMode } from 'react'
|
|||
import { createRoot } from 'react-dom/client'
|
||||
import App from './App'
|
||||
|
||||
if (import.meta.env.DEV) {
|
||||
import('react-grab').then(({ init }) => init())
|
||||
import('react-grab/styles.css')
|
||||
}
|
||||
|
||||
// Respect system dark mode preference
|
||||
function applySystemTheme(): void {
|
||||
const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches
|
||||
|
|
|
|||
Loading…
Reference in a new issue