Skip to content

Commit

Permalink
enhance(search): explicitly focus search input
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelgerber committed Sep 19, 2024
1 parent 2f79b61 commit 7ba1202
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions site/search/Autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,14 @@ export function Autocomplete({
// Register a global shortcut to open the search box on typing "/"
useEffect(() => {
if (!search) return

Mousetrap.bind("/", (e) => {
e.preventDefault() // don't type "/" into input
search.setIsOpen(true)

const input =
containerRef.current?.querySelector<HTMLInputElement>("input")
input?.focus()
})

return () => {
Expand Down

0 comments on commit 7ba1202

Please sign in to comment.