Skip to content

Commit

Permalink
Check if flatpickr instance is available before destroying it to ensu…
Browse files Browse the repository at this point in the history
…re we don't run destroy on uninitialized elements
  • Loading branch information
andrew-mykhalchuk committed Jul 24, 2024
1 parent e2bc3ef commit e668dc5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/assets/javascripts/spree/backend/global/flatpickr.es6
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
})
})

0 comments on commit e668dc5

Please sign in to comment.