From 328a527b49526b4c700edfb27ec274955908675c Mon Sep 17 00:00:00 2001 From: Allan Lasser Date: Wed, 24 Apr 2024 13:15:30 -0400 Subject: [PATCH] Handle empty queries better --- src/routes/app/add-ons/+page.svelte | 1 - src/routes/app/projects/+page.svelte | 1 - src/routes/app/projects/[id]-[slug]/+page.ts | 4 ++-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/routes/app/add-ons/+page.svelte b/src/routes/app/add-ons/+page.svelte index 82d97bd49..dd15175bf 100644 --- a/src/routes/app/add-ons/+page.svelte +++ b/src/routes/app/add-ons/+page.svelte @@ -39,7 +39,6 @@ const url = new URL($page.url); // make a copy const formData = new FormData(event.currentTarget as HTMLFormElement); const query = formData.get("query") ?? ""; - if (!query) return; url.searchParams.set("query", query as string); goto(url); } diff --git a/src/routes/app/projects/+page.svelte b/src/routes/app/projects/+page.svelte index 53e2e94ed..0ee16daf3 100644 --- a/src/routes/app/projects/+page.svelte +++ b/src/routes/app/projects/+page.svelte @@ -22,7 +22,6 @@ const url = new URL($page.url); // make a copy const formData = new FormData(event.currentTarget as HTMLFormElement); const query = formData.get("query") ?? ""; - if (!query) return; url.searchParams.set("query", query as string); goto(url); } diff --git a/src/routes/app/projects/[id]-[slug]/+page.ts b/src/routes/app/projects/[id]-[slug]/+page.ts index b8ba2b18a..9b07b3f91 100644 --- a/src/routes/app/projects/[id]-[slug]/+page.ts +++ b/src/routes/app/projects/[id]-[slug]/+page.ts @@ -8,8 +8,8 @@ export async function load({ params, url, parent, fetch }) { const breadcrumbs = await breadcrumbTrail(parent, [ { href: url.pathname, title: project.title }, ]); - const query = url.searchParams.get("q"); - const cursor = url.searchParams.get("cursor"); + const query = url.searchParams.get("q") ?? ""; + const cursor = url.searchParams.get("cursor") ?? ""; const documents = search(query, { cursor, project: project.id }); return { breadcrumbs,