Skip to content

Commit

Permalink
perf(searchfilters): debounce the date slider
Browse files Browse the repository at this point in the history
  • Loading branch information
jmiguelv committed Dec 10, 2024
1 parent 1d6d62b commit cd51bcd
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions frontend/src/lib/components/search/SearchFilters.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script>
import { slide } from 'svelte/transition';
import { Slider } from 'bits-ui';
import debounce from 'lodash.debounce';
import { slide } from 'svelte/transition';
let {
show = false,
Expand All @@ -15,6 +16,16 @@
{ label: 'Count', value: 'count' }
];
let currentDateRange = $state(selectedDateRange);
const updateSelectedDateRange = debounce((newValue) => {
selectedDateRange = newValue;
}, 300);
$effect(() => {
updateSelectedDateRange([...currentDateRange]);
});
/** @type {Record<string, string>} */
let filterContains = $state({});
Expand Down Expand Up @@ -101,7 +112,7 @@
min={-700}
max={1830}
step={1}
bind:value={selectedDateRange}
bind:value={currentDateRange}
let:thumbs
>
<span class="slider-track">
Expand All @@ -119,11 +130,11 @@
<div class="date-inputs">
<label>
Not before
<input type="number" bind:value={selectedDateRange[0]} min={-700} max={1811} />
<input type="number" bind:value={currentDateRange[0]} min={-700} max={1811} />
</label>
<span></span>
<label>
<input type="number" bind:value={selectedDateRange[1]} min={-675} max={1830} />
<input type="number" bind:value={currentDateRange[1]} min={-675} max={1830} />
Not after
</label>
</div>
Expand Down

0 comments on commit cd51bcd

Please sign in to comment.