diff --git a/src/components/search/SearchBar/searchBar.tsx b/src/components/search/SearchBar/searchBar.tsx index dd371973..836f7ae9 100644 --- a/src/components/search/SearchBar/searchBar.tsx +++ b/src/components/search/SearchBar/searchBar.tsx @@ -189,6 +189,15 @@ const SearchBar = ({ } } + function handleKeyDown(event: React.KeyboardEvent) { + if (event.key === 'Enter' && inputValue === '') { + console.log('handleKeyDown'); + event.preventDefault(); + event.stopPropagation(); + onSelect_internal(value); + } + } + useEffect(() => { fetch('/api/autocomplete'); }, []); @@ -241,6 +250,7 @@ const SearchBar = ({ loadNewOptions(newInputValue); }} renderInput={(params) => { + params.inputProps.onKeyDown = handleKeyDown; return ( { + console.log('onInput'); const value = (event.target as HTMLInputElement).value; // if the last character in the new string is a space, check for autocomplete if (