diff --git a/apps/storefront/src/components/header/search-form.tsx b/apps/storefront/src/components/header/search-form.tsx index ea7ef7f..e292bfd 100644 --- a/apps/storefront/src/components/header/search-form.tsx +++ b/apps/storefront/src/components/header/search-form.tsx @@ -130,13 +130,13 @@ export const SearchForm = ({ onSubmit }: { onSubmit?: () => void }) => { } }; - const handleSearchIconClick = () => { + const handleSubmit = (event: React.FormEvent) => { + event.preventDefault(); + if (isNoOptionHighlighted || isLastOptionHighlighted) { router.push(paths.search.asPath({ query: { q: inputValue } })); - resetSearchState(); - - return; } + resetSearchState(); }; useClickAnyWhere(() => @@ -176,6 +176,7 @@ export const SearchForm = ({ onSubmit }: { onSubmit?: () => void }) => { action={performSearch} aria-label={ts("site-wide-search-form")} role="search" + onSubmit={handleSubmit} > void }) => { type="submit" variant="outline" className="cursor-pointer" - onClick={handleSearchIconClick} > {isLoading ? (