feat: add global escape key handling to close search modal
This commit is contained in:
@@ -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...
|
||||
|
||||
Reference in New Issue
Block a user