Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix redirection after search icon clicking #25

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions apps/storefront/src/components/header/search-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ export const SearchForm = ({ onSubmit }: { onSubmit?: () => void }) => {
}
};

const handleSearchIconClick = () => {
const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();

if (isNoOptionHighlighted || isLastOptionHighlighted) {
router.push(paths.search.asPath({ query: { q: inputValue } }));
resetSearchState();

return;
}
resetSearchState();
};

useClickAnyWhere(() =>
Expand Down Expand Up @@ -176,6 +176,7 @@ export const SearchForm = ({ onSubmit }: { onSubmit?: () => void }) => {
action={performSearch}
aria-label={ts("site-wide-search-form")}
role="search"
onSubmit={handleSubmit}
>
<Combobox className="z-50">
<ComboboxInput
Expand All @@ -186,7 +187,6 @@ export const SearchForm = ({ onSubmit }: { onSubmit?: () => void }) => {
type="submit"
variant="outline"
className="cursor-pointer"
onClick={handleSearchIconClick}
>
{isLoading ? (
<Spinner size={16} />
Expand Down