Repository: flatpickr/flatpickr (ts)

Issue:
Calendar show wrong when set minDate
I have a problem when setting minDate
When I set start date = someday in next month and set minDate of the end date is that day, when I open end date calendar, It still displays the current date, I think it wrong

Sorry about my skill English, you can check it in https://jsfiddle.net/Lt08j61p/1/

vue-flatpickr issue: https://github.com/ankurk91/vue-flatpickr-component/issues/136

Pull request description:
Fixed calendar not jumping to date after minDate or maxDate or changed
This fixes #1728 . This particular problem appeared after `jumpToDate()` was removed in #1676

Patch:
diff --git a/src/index.ts b/src/index.ts
index 6d019598..4d19c81c 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -2210,15 +2210,21 @@ function FlatpickrInstance(
   const CALLBACKS: { [k in keyof Options]: Function[] } = {
     locale: [setupLocale, updateWeekdays],
     showMonths: [buildMonths, setCalendarWidth, buildWeekdays],
+    minDate: [jumpToDate],
+    maxDate: [jumpToDate],
   };
 
   function set<K extends keyof Options>(
     option: K | { [k in K]?: Options[k] },
     value?: any
   ) {
-    if (option !== null && typeof option === "object")
+    if (option !== null && typeof option === "object") {
       Object.assign(self.config, option);
-    else {
+      for (const key in option) {
+        if (CALLBACKS[key] !== undefined)
+          (CALLBACKS[key] as Function[]).forEach(x => x());
+      }
+    } else {
       self.config[option] = value;
 
       if (CALLBACKS[option] !== undefined)
@@ -2293,6 +2299,9 @@ function FlatpickrInstance(
     jumpToDate();
 
     setHoursFromDate();
+    if (self.selectedDates.length === 0) {
+      self.clear(false);
+    }
     updateValue(triggerChange);
 
     if (triggerChange) triggerEvent("onChange");
@@ -2591,8 +2600,6 @@ function FlatpickrInstance(
    * Updates the values of inputs associated with the calendar
    */
   function updateValue(triggerChange = true) {
-    if (self.selectedDates.length === 0) return self.clear(triggerChange);
-
     if (self.mobileInput !== undefined && self.mobileFormatStr) {
       self.mobileInput.value =
         self.latestSelectedDateObj !== undefined


Test patch:
diff --git a/src/__tests__/index.spec.ts b/src/__tests__/index.spec.ts
index f618ddc4..70195ce1 100644
--- a/src/__tests__/index.spec.ts
+++ b/src/__tests__/index.spec.ts
@@ -491,6 +491,18 @@ describe("flatpickr", () => {
       expect(fp.config.mode).toEqual("range");
     });
 
+    it("set() minDate/maxDate updates current view", () => {
+      createInstance();
+      const now = new Date();
+      const nextMonth = new Date();
+      nextMonth.setMonth(now.getMonth() + 1);
+
+      expect(fp.currentMonth).toEqual(now.getMonth());
+
+      fp.set("minDate", nextMonth);
+      expect(fp.currentMonth).toEqual(nextMonth.getMonth());
+    });
+
     it("setDate (date)", () => {
       createInstance({
         enableTime: true,