Skip to content

Commit cf390e9

Browse files
committed
Clear date filter inputs when clicking "Clear"
1 parent cf15b28 commit cf390e9

File tree

1 file changed

+48
-44
lines changed

1 file changed

+48
-44
lines changed

desktop-app/src/components/ResultGrid.svelte

Lines changed: 48 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
4040
let fromDateInput = $state('');
4141
let toDateInput = $state('');
42+
let datePickerResetKey = $state(0);
4243
let appliedFilters = $state<DateFilterState>({
4344
fromDate: '',
4445
toDate: ''
@@ -167,6 +168,7 @@
167168
function clearFilters() {
168169
fromDateInput = '';
169170
toDateInput = '';
171+
datePickerResetKey += 1;
170172
const cleared: DateFilterState = {
171173
fromDate: '',
172174
toDate: ''
@@ -198,50 +200,52 @@
198200
onreset={resetFilters}
199201
>
200202
<div class="result-grid__filters-row result-grid__filters-row--main">
201-
<div class="result-grid__filters-fields">
202-
<DatePicker>
203-
<DatePickerInput
204-
id="result-grid-from-date"
205-
size="sm"
206-
labelText="From date"
207-
placeholder="mm/dd/yyyy"
208-
bind:value={fromDateInput}
209-
on:input={(event) => {
210-
fromDateInput = readInputValue(event);
211-
}}
212-
>
213-
<span slot="labelText" class="result-grid__date-label">
214-
<span>From date</span>
215-
<TooltipIcon
216-
tooltipText="Starting from midnight on the specified start date"
217-
>
218-
<Information />
219-
</TooltipIcon>
220-
</span>
221-
</DatePickerInput>
222-
</DatePicker>
223-
<DatePicker>
224-
<DatePickerInput
225-
id="result-grid-to-date"
226-
size="sm"
227-
labelText="To date"
228-
placeholder="mm/dd/yyyy"
229-
bind:value={toDateInput}
230-
on:input={(event) => {
231-
toDateInput = readInputValue(event);
232-
}}
233-
>
234-
<span slot="labelText" class="result-grid__date-label">
235-
<span>To date</span>
236-
<TooltipIcon
237-
tooltipText="Up to (but not including) the specified end date"
238-
>
239-
<Information />
240-
</TooltipIcon>
241-
</span>
242-
</DatePickerInput>
243-
</DatePicker>
244-
</div>
203+
{#key datePickerResetKey}
204+
<div class="result-grid__filters-fields">
205+
<DatePicker>
206+
<DatePickerInput
207+
id="result-grid-from-date"
208+
size="sm"
209+
labelText="From date"
210+
placeholder="mm/dd/yyyy"
211+
bind:value={fromDateInput}
212+
on:input={(event) => {
213+
fromDateInput = readInputValue(event);
214+
}}
215+
>
216+
<span slot="labelText" class="result-grid__date-label">
217+
<span>From date</span>
218+
<TooltipIcon
219+
tooltipText="Starting from midnight on the specified start date"
220+
>
221+
<Information />
222+
</TooltipIcon>
223+
</span>
224+
</DatePickerInput>
225+
</DatePicker>
226+
<DatePicker>
227+
<DatePickerInput
228+
id="result-grid-to-date"
229+
size="sm"
230+
labelText="To date"
231+
placeholder="mm/dd/yyyy"
232+
bind:value={toDateInput}
233+
on:input={(event) => {
234+
toDateInput = readInputValue(event);
235+
}}
236+
>
237+
<span slot="labelText" class="result-grid__date-label">
238+
<span>To date</span>
239+
<TooltipIcon
240+
tooltipText="Up to (but not including) the specified end date"
241+
>
242+
<Information />
243+
</TooltipIcon>
244+
</span>
245+
</DatePickerInput>
246+
</DatePicker>
247+
</div>
248+
{/key}
245249
<div class="result-grid__filters-actions">
246250
{#if isReloadingData && hasInitiallyLoaded}
247251
<div class="result-grid__soft-loading" aria-live="polite">

0 commit comments

Comments
 (0)