feat: add global escape key handling to close search modal
Some checks failed
Frontend CI / lint (push) Failing after 17s
Frontend CI / build (push) Has been skipped

This commit is contained in:
JSC
2025-10-04 14:41:59 +02:00
parent adf16210a4
commit 7d94e29dcb

View File

@@ -159,6 +159,20 @@ export function GlobalSearch({ isOpen, onClose }: GlobalSearchProps) {
}
}
// Handle global escape key
useEffect(() => {
if (!isOpen) return
const handleGlobalKeyDown = (e: KeyboardEvent) => {
if (e.key === 'Escape') {
onClose()
}
}
window.addEventListener('keydown', handleGlobalKeyDown)
return () => window.removeEventListener('keydown', handleGlobalKeyDown)
}, [isOpen, onClose])
if (!isOpen) return null
return (
@@ -193,8 +207,8 @@ export function GlobalSearch({ isOpen, onClose }: GlobalSearchProps) {
</div>
{/* Results */}
<ScrollArea className="max-h-[60vh]">
<div className="p-2 max-h-[60vh] overflow-y-auto">
<ScrollArea className="h-[60vh]">
<div className="p-2">
{loading && (
<div className="p-4 text-center text-muted-foreground">
Searching...