From c6df3be42bf52505f2a9d7082c120359be801c82 Mon Sep 17 00:00:00 2001 From: gnbm Date: Tue, 7 Jul 2026 20:34:42 +0100 Subject: [PATCH] ROU-12898 fix DatePicker onChange not firing on manual -1 day entry The onBlur change-detection compared the typed value against new Date(hiddenInputValue). For a date-only value ("Y-m-d") the Date constructor parses it as UTC midnight, which renders as the previous day under negative timezone offsets. A manual entry of the previous day therefore looked unchanged, so setDate/onChange were suppressed (a -2 day entry still differed and fired). Parse the hidden value with flatpickr's own parseDate (local time) using config.dateFormat instead, and treat an unparseable value as changed. --- src/index.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index ff826a9d6..e7afa8bb3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1776,9 +1776,19 @@ function FlatpickrInstance( if (self.config.altInput) { const hiddenInputValue = self.element.getAttribute("value") as string; + // Parse the hidden value with flatpickr's own parser (local time) rather + // than new Date(), whose date-only ("Y-m-d") parsing is treated as UTC and + // therefore shifts to the previous day under negative timezone offsets, + // making a one-day-earlier manual entry look unchanged and suppressing + // onChange. undefined => no valid baseline => treat the value as changed. + const parsedHiddenDate = self.parseDate( + hiddenInputValue, + self.config.dateFormat + ); valueChanged = + parsedHiddenDate === undefined || self._input.value.trimEnd() !== - self.formatDate(new Date(hiddenInputValue), self.config.altFormat); + self.formatDate(parsedHiddenDate, self.config.altFormat); } if (