Skip to content

Commit 0b99981

Browse files
committed
fix bug where you can't link to search queries
1 parent dd7a646 commit 0b99981

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/routes/scripts.svelte

+6-4
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@
3838
})
3939
4040
let searchValue = $page.query.get('search') ?? ''
41-
42-
const handleSearchChange = (event: TextInputChangeEvent) =>
43-
(searchValue = event.detail.parsedValue)
41+
let shouldUpdateUrlQuery = false
42+
const handleSearchChange = (event: TextInputChangeEvent) => {
43+
searchValue = event.detail.parsedValue
44+
shouldUpdateUrlQuery = true
45+
}
4446
4547
type DisplayedDocuments = { items: Set<number>; first: number; last: number }
4648
const searchCache: {
@@ -69,7 +71,7 @@
6971
searchCache[currentSearch] = displayedDocuments
7072
}
7173
}
72-
$: if (typeof window !== 'undefined') {
74+
$: if (typeof window !== 'undefined' && shouldUpdateUrlQuery) {
7375
window.history.replaceState(
7476
null,
7577
'',

0 commit comments

Comments
 (0)