Skip to content

[BUG] calendar.set({ displayDateMin/displayDateMax: undefined }) does not reset to library defaults #413

@envyvox

Description

@envyvox

Describe the bug
When displayDateMin or displayDateMax are set via calendar.set() and later updated with undefined, the calendar keeps the previous constraints. Disabled dates remain disabled instead of reverting to the default range.
This makes it hard to dynamically clear min/max limits in reactive UIs (e.g. when a filter preset is cleared).

Steps to reproduce

<script type="module">
  import { Calendar } from 'vanilla-calendar-pro';
  const input = document.getElementById('date-input');
  const calendar = new Calendar(input, { inputMode: true });
  calendar.init();
  calendar.set({
    displayDateMin: '2026-06-01',
    displayDateMax: '2026-06-30',
  });
  // Later: try to clear limits
  calendar.set({
    displayDateMin: undefined,
    displayDateMax: undefined,
  });
</script>
<input id="date-input" />

Expected behavior
Passing undefined for displayDateMin / displayDateMax should reset them to the library defaults (same as on first init), and dates outside the previous range should become selectable again.

CodeSandbox example (REQUIRED)
https://codesandbox.io/p/sandbox/5xq5sf

  1. Click 1. Set range (Jun 2026) → open calendar → only June dates are enabled.
  2. Click 2. Clear with undefined → open calendar → dates outside June are still disabled (bug).
  3. Click 3. Clear with defaults → open calendar → all dates are enabled (workaround).

Additional context
As current workaround - explicitly pass the default boundary strings instead of undefined:

calendar.set({
  displayDateMin: minDate ? formatDate(minDate) : '1970-01-01',
  displayDateMax: maxDate ? formatDate(maxDate) : '2470-12-31',
});

(These match the internal defaults we found in the source: dateMin / dateMax default to '1970-01-01' and '2470-12-31'.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions