Skip to content

Range calendar jalali onchange undefined problem#247

Merged
farhoudshapouran merged 1 commit into
farhoudshapouran:mainfrom
sinabdollahi:fix/range-calendar-jalali-onChange-problem
Apr 14, 2026
Merged

Range calendar jalali onchange undefined problem#247
farhoudshapouran merged 1 commit into
farhoudshapouran:mainfrom
sinabdollahi:fix/range-calendar-jalali-onChange-problem

Conversation

@sinabdollahi

@sinabdollahi sinabdollahi commented Apr 7, 2026

Copy link
Copy Markdown
Collaborator

This fixes #246

  • dateToUnix now returns NaN for empty values instead of “now”.
  • Prevents false comparisons when no start/end exists yet.
  • isDateBetween now uses numeric timestamps explicitly.
  • Removes fragile object coercion behavior and keeps comparisons deterministic.
  • removeTime now normalizes from an existing parsed date and only applies timezone when needed.
  • Avoids double/ambiguous parsing.
  • days.tsx now checks startDate && endDate before “same-day range” comparison.
  • Prevents accidentally evaluating dayjs(undefined) and collapsing range styling.
  • onChange in range mode now converts already-normalized dates directly.

- So in short: it fixed because we made the range pipeline strictly compare real dates only, never “fallback now”, and avoid double parsing — which was especially visible in Jalali mode.

@farhoudshapouran farhoudshapouran merged commit bd2b230 into farhoudshapouran:main Apr 14, 2026
1 check passed
@farhoudshapouran

Copy link
Copy Markdown
Owner

Thanks @sinabdollahi — I reviewed the changes carefully, and they all look good:

dateToUnix → NaN — correctly fixes the silent "fallback to now" issue that caused the reset-on-first-tap symptom
isDateBetween numeric comparison — safer and deterministic
removeTime conditional .tz() — good defensive change
days.tsx startDate/endDate guard — fixes a real range-highlight bug
✅ Range onChange simplification — verified Gregorian + timezone still emits correct dates

Merging. Thanks for the careful work and the clear description.

While testing, I found that calendar="jalali" + timeZone="Asia/Tehran" + mode="range" still crashes with RangeError: Invalid time value and emits dates with year 1405 AD. This bug exists on main too (pre-existing), so this PR doesn't introduce it.

Root cause: jalali-plugin-dayjs mutates global dayjs state and interacts badly with dayjs.tz() + .startOf('day').

I'll open a separate issue to track the Jalali + timezone fix. It likely requires a library-level change (replacing the plugin).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mode="range" with calendar="jalali", onChange endDate is always undefined and start date does not trigger anything.

2 participants