From ede5cdd8cf5575bba96d3e7b6824a7ad7b414ea7 Mon Sep 17 00:00:00 2001 From: kolaente Date: Fri, 23 Sep 2022 10:36:21 +0200 Subject: [PATCH] fix: only pass date to flatpickr if it's a valid date Resolves #2384 --- src/components/date/datepickerWithRange.vue | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/date/datepickerWithRange.vue b/src/components/date/datepickerWithRange.vue index e27acf7a..23181279 100644 --- a/src/components/date/datepickerWithRange.vue +++ b/src/components/date/datepickerWithRange.vue @@ -118,7 +118,13 @@ watch( newValue => { from.value = newValue.dateFrom to.value = newValue.dateTo - flatpickrRange.value = `${from.value} to ${to.value}` + // Only set the date back to flatpickr when it's an actual date. + // Otherwise flatpickr runs in an endless loop and slows down the browser. + const dateFrom = new Date(from.value) + const dateTo = new Date(to.value) + if (dateTo.getTime() === dateTo.getTime() && dateFrom.getTime() === dateFrom.getTime()) { + flatpickrRange.value = `${from.value} to ${to.value}` + } }, )