Skip to content

Commit

Permalink
Only show search results if search term is not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
armans-code committed Oct 19, 2024
1 parent b776ee1 commit 58e9019
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/components/search-dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ export function SearchDropdownComponent() {

useEffect(() => {
const search = async () => {
const results = await searchProducts(searchTerm);
setFilteredItems(results);
if (searchTerm.length === 0) setFilteredItems([]);
else {
const results = await searchProducts(searchTerm);
setFilteredItems(results);
}
};

search();
Expand Down

0 comments on commit 58e9019

Please sign in to comment.