Skip to content

Commit

Permalink
Debounce query changes
Browse files Browse the repository at this point in the history
  • Loading branch information
allanlasser committed Feb 20, 2024
1 parent 255ca6d commit 599d43a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/common/SearchInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
import { writable } from "svelte/store";
export const query = writable("");
let timer;
let delay = 100;
const debounce = (v, fn) => {
clearTimeout(timer);
timer = setTimeout(() => {
fn(v);
}, delay);
};
</script>

<script>
Expand All @@ -13,7 +22,7 @@
<Search size={0.8} />
<input
type="search"
bind:value={$query}
on:change={({ currentTarget: { value } }) => debounce(value, query.set)}
aria-label="Search Add-Ons"
placeholder={$_("addonBrowserDialog.searchPlaceholder")}
/>
Expand Down

0 comments on commit 599d43a

Please sign in to comment.