Skip to content

Commit

Permalink
fix liveseries search for non-JS clients
Browse files Browse the repository at this point in the history
  • Loading branch information
kguzek committed Jan 4, 2025
1 parent 3eaf4e3 commit 0ebc392
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/app/liveseries/search/search-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,23 @@ export function SearchForm({ userLanguage }: { userLanguage: Language }) {
const data = TRANSLATIONS[userLanguage];

function getSearchPath() {
const query = new URLSearchParams({ q: inputValue.trim() });
const trimmed = inputValue.trim();
if (!trimmed) return "";
const query = new URLSearchParams({ q: trimmed });
return `/liveseries/search?${query}`;
}

const path = getSearchPath();

return (
<form
className="form-editor flex items-center gap-4"
onSubmit={(evt) => {
evt.preventDefault();
router.push(getSearchPath());
}}
action="/liveseries/search"
method="get"
>
<InputBox
label={data.liveSeries.search.label}
Expand All @@ -33,15 +39,15 @@ export function SearchForm({ userLanguage }: { userLanguage: Language }) {
required={true}
placeholder={data.liveSeries.search.prompt}
autofocus
name="q"
/>
<Link
href={getSearchPath()}
role="submit"
className="btn"
style={{ minWidth: "unset" }}
>
{data.liveSeries.search.search}
</Link>
{path ? (
<Link href={path} role="submit" className="btn">
{data.liveSeries.search.search}
</Link>
) : (
<button className="btn">{data.liveSeries.search.search}</button>
)}
</form>
);
}

0 comments on commit 0ebc392

Please sign in to comment.