diff --git a/src/lib/components/viewer/Search.svelte b/src/lib/components/viewer/Search.svelte index 2b27bd3a4..78f6df559 100644 --- a/src/lib/components/viewer/Search.svelte +++ b/src/lib/components/viewer/Search.svelte @@ -19,7 +19,7 @@ Assumes it's a child of a ViewerContext import Error from "../common/Error.svelte"; const document = getDocument(); - let query = getQuery($page.url, "q"); + let search: Promise<[number, string[]][]>; // Format page numbers, highlight search results, and remove invalid pages function formatResults(results: APIResponse) { @@ -34,7 +34,7 @@ Assumes it's a child of a ViewerContext .filter(([page]) => !isNaN(page)); } - let search: Promise<[number, string[]][]>; + $: query = getQuery($page.url, "q"); $: search = searchWithin($document.id, query).then(formatResults); @@ -46,7 +46,12 @@ Assumes it's a child of a ViewerContext {:then resultsPages} {#each resultsPages as [pageNumber, resultsList]}