Skip to content

Commit

Permalink
Update SearchBox.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
kuck1 committed Mar 24, 2024
1 parent 3283279 commit 0f3cdd7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/ui/components/core/SearchBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { Trans, useTranslation } from 'next-i18next'
import {
type Dispatch,
forwardRef,
type KeyboardEventHandler,

Check warning on line 22 in packages/ui/components/core/SearchBox.tsx

View check run for this annotation

InReachBot / Check Code for Errors

packages/ui/components/core/SearchBox.tsx#L22

[@typescript-eslint/no-unused-vars] 'KeyboardEventHandler' is defined but never used. Allowed unused vars must match /^_/u.
type ReactNode,
type SetStateAction,
useDebugValue,
Expand Down Expand Up @@ -348,6 +349,15 @@ export const SearchBox = ({
}
}

const handleKeyDown: React.KeyboardEventHandler<HTMLInputElement> = (event) => {
if (event.key === 'Enter') {
const topItem = results[0]
if (topItem) {
selectionHandler(topItem)
}
}
}

return (
<Autocomplete
classNames={{
Expand All @@ -363,6 +373,7 @@ export const SearchBox = ({
dropdownPosition='bottom'
radius='xl'
onItemSubmit={selectionHandler}
onKeyDown={handleKeyDown}
disabled={isLoading}
label={label}
withinPortal
Expand Down

0 comments on commit 0f3cdd7

Please sign in to comment.