Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the DatePicker (flatpickr) failing to fire
onChangewhen a user manually types a date one day earlier than the currently selected date, under negative timezone offsetsRoot cause
onBlurgates whether to callsetDate(..., true, ...)(which firesonChange) on avalueChangedcheck:With
TimeFormat.Disabledthe hidden value is a date-only string (e.g."2026-06-25"). Per ECMAScript, a date-only string passed tonew Date()is parsed as UTC midnight. Under a negative UTC offset (e.g. UTC−02:00) that instant renders as the previous day in local time, soformatDate(...)returns"2026-06-24".Consequently, after selecting today and typing the previous day, the typed value equals the (shifted) baseline →
valueChanged = false→setDate/onChangeare skipped. Typing −2 days differs from the shifted baseline, so it still fires — matching the ticket's exact signature ("−1 fails, −2 works, negative offsets only").Fix
Parse the hidden value with flatpickr's own
self.parseDate(hiddenInputValue, self.config.dateFormat), which builds the date from local components (no UTC shift), consistent with the rest of flatpickr. An unparseable/empty value is treated as changed soonChangeis not wrongly suppressed.Testing
npm run test:typecheck— passes.npm run test:unit— 4 failed / 107 passed, identical tomasterbaseline (the same 4 pre-existing failures:API destroy(),onKeyDown ... Enter,time-picker focuses out,onBlur doesn't misfire). This change adds no new failures.npm run build— succeeds; fix present indist/flatpickr.jsanddist/esm/index.js.