Flatpicker: remove “enable” property

I am trying to dynamically re-enable all dates after previously restricting some dates using the enable settings.

However, I’ve come across an interesting workaround that involves setting _enable to undefined. This successfully made all dates selectable again, but it feels wrong.

Here’s the code snippet:

// Initialize Flatpickr
const picker = flatpickr("#datepicker", {
  enableTime: false,
  dateFormat: "Y-m-d",
});

// Enable only a specific range of dates
picker.set("enable", ["2023-11-01", "2023-11-10"]);

// Later, reset to make all dates selectable again
picker.set("_enable", undefined); // <-- This works, but feels like a hack

My Questions:

  1. Why does using _enable work?

    • I assume this is some internal or hidden property, but I couldn’t find any documentation explaining it. Is it safe to use in production?
  2. What is the “normal” or official way to re-enable all dates?

  • picker.set("enable", []); works, but sets everything to disabled (no enabled dates)
  • picker.set("enable", undefinde); or picker.set("enable", null); with error:
flatpickr:2 Uncaught TypeError: Cannot read properties of undefined (reading 'slice')
    at he (flatpickr:2:35009)
    at Object.set (flatpickr:2:37988)
    at w.set (flatpickr:2:33474)
    at HTMLButtonElement.<anonymous> (_display/:59:14)

Here is the full “working” demo on jsfiddle