From e668dc5ee25e99acdc5f7ccb9d4f38562a567627 Mon Sep 17 00:00:00 2001 From: Andrew Mykhalchuk Date: Wed, 24 Jul 2024 13:47:50 +0300 Subject: [PATCH] Check if flatpickr instance is available before destroying it to ensure we don't run destroy on uninitialized elements --- app/assets/javascripts/spree/backend/global/flatpickr.es6 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/spree/backend/global/flatpickr.es6 b/app/assets/javascripts/spree/backend/global/flatpickr.es6 index cdf033f063..73fa7ebee3 100644 --- a/app/assets/javascripts/spree/backend/global/flatpickr.es6 +++ b/app/assets/javascripts/spree/backend/global/flatpickr.es6 @@ -23,7 +23,9 @@ document.addEventListener("spree:load", function() { document.addEventListener("turbo:before-cache", function() { document.querySelectorAll('.datePickerFrom, .datePickerTo, .datepicker').forEach(function(element) { - element._flatpickr.destroy() + if (element._flatpickr) { + element._flatpickr.destroy() + } }) })