From 43fb581fde922f25ab02c2fb4c1d908ae976b5c0 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 17 Nov 2022 10:16:27 +0000 Subject: [PATCH] Fix flatpickr random error --- packages/bbui/src/Form/Core/DatePicker.svelte | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/bbui/src/Form/Core/DatePicker.svelte b/packages/bbui/src/Form/Core/DatePicker.svelte index 379f41b284..5510d2d25b 100644 --- a/packages/bbui/src/Form/Core/DatePicker.svelte +++ b/packages/bbui/src/Form/Core/DatePicker.svelte @@ -23,6 +23,15 @@ let open = false let flatpickr, flatpickrOptions + // Another classic flatpickr issue. Errors were randomly being thrown due to + // flatpickr internal code. Making sure that "destroy" is a valid function + // fixes it. The sooner we remove flatpickr the better. + $: { + if (flatpickr && !flatpickr.destroy) { + flatpickr.destroy = () => {} + } + } + const resolveTimeStamp = timestamp => { let maskedDate = new Date(`0-${timestamp}`)