diff --git a/src/components/searchBar/DebouncedSearchBar.tsx b/src/components/searchBar/DebouncedSearchBar.tsx index 6e16af7..334c1dd 100644 --- a/src/components/searchBar/DebouncedSearchBar.tsx +++ b/src/components/searchBar/DebouncedSearchBar.tsx @@ -59,8 +59,9 @@ export const DebouncedSearchBar = ({ setSelectedIndex(Math.max(selectedIndex - 1, 0)); break; case 'Enter': - if (searchResults && searchResults[selectedIndex]) { - onClick?.(searchResults[selectedIndex]); + const selectedItem = searchResults?.[selectedIndex]; + if (selectedItem) { + onClick?.(selectedItem); } break; }