Adam McQuilkin
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
9 additions and
6 deletions
-
src/components/CommandPalette/Index.tsx
|
|
|
@ -12,7 +12,7 @@ |
|
|
|
*/ |
|
|
|
|
|
|
|
import type React from "react"; |
|
|
|
import { Fragment, useState } from "react"; |
|
|
|
import { Fragment, useEffect, useState } from "react"; |
|
|
|
|
|
|
|
import { toast } from "react-hot-toast"; |
|
|
|
|
|
|
|
@ -211,14 +211,17 @@ export const CommandPalette = (): JSX.Element => { |
|
|
|
}, |
|
|
|
]; |
|
|
|
|
|
|
|
window.addEventListener("keydown", (e) => { |
|
|
|
if (e.key === "k") { |
|
|
|
e.preventDefault(); |
|
|
|
} |
|
|
|
const handleKeydown = (e: KeyboardEvent) => { |
|
|
|
if (e.key === "k" && (e.metaKey || e.ctrlKey)) { |
|
|
|
e.preventDefault(); |
|
|
|
setOpen(true); |
|
|
|
} |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
window.addEventListener("keydown", handleKeydown); |
|
|
|
return () => window.removeEventListener("keydown", handleKeydown); |
|
|
|
}, []); |
|
|
|
|
|
|
|
const filtered = |
|
|
|
query === "" |
|
|
|
|