⚙️ Listen to search params to clear results

This commit is contained in:
Jared Muñoz 2024-10-28 11:46:53 -06:00
parent cf2efef10a
commit 82a6dfb097

View File

@ -1,4 +1,5 @@
<script lang="ts"> <script lang="ts">
import { page } from '$app/stores';
import { inputStyles } from '@/ui/styles'; import { inputStyles } from '@/ui/styles';
import { Command, SearchIcon } from 'lucide-svelte'; import { Command, SearchIcon } from 'lucide-svelte';
export let searchTerm: string; export let searchTerm: string;
@ -24,6 +25,17 @@
} }
}; };
} }
let searchParams = {} as { [key: string]: string };
$: {
if ($page) {
searchParams = Object.fromEntries($page.url.searchParams);
if (!searchParams?.search) {
clearSearch();
}
}
}
</script> </script>
<div class="sticky top-[63px] z-50"> <div class="sticky top-[63px] z-50">