fix(Search): replace window.history.pushState with goto

This commit is contained in:
afn 2023-04-20 22:36:42 -04:00
parent 9734d9f64b
commit 77f0337445
2 changed files with 8 additions and 4 deletions

View File

@ -1,14 +1,17 @@
<script lang="ts">
import { fade } from 'svelte/transition';
import { quintOut } from 'svelte/easing';
import { page } from '$app/stores';
import { goto } from '$app/navigation';
export let title: string;
export let searchTerm: string | null;
export let searchTermFiltered: string | undefined;
import { fade } from 'svelte/transition';
import { quintOut } from 'svelte/easing';
function clear() {
searchTerm = '';
searchTermFiltered = '';
window.history.pushState(null, '', window.location.href.split('?')[0])
goto($page.url.pathname)
}
</script>

View File

@ -2,6 +2,7 @@
import { fly } from 'svelte/transition';
import { quintOut } from 'svelte/easing';
import { page } from '$app/stores';
import { goto } from '$app/navigation';
import type { PageData } from './$types';
import type { Patch } from '$lib/types';
@ -78,7 +79,7 @@
.replace(/-/g, '')
.toLowerCase();
// Update search URL params
window.history.pushState(null, '', `${window.location.href.split('?')[0]}${searchTerm ? '?s=' + searchTerm : ''}`)
goto(`${$page.url.pathname}${searchTerm ? '?s=' + searchTerm : ''}`)
}, 500);
};
</script>