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() + } }) })