Skip to content

Conversation

@endaaman
Copy link

I've been using this library in production and it's been incredibly helpful. However, I needed the ability to specify a default date for the picker instead of always using new Date().

Changes

  • Added defaultDate prop to DateInput component
  • Added defaultDate prop to DatePicker component

Usage

<DateInput defaultDate={new Date(2024, 0, 1)} />

@probablykasper
Copy link
Owner

How is this different than supplying a date to the value prop?

@endaaman
Copy link
Author

endaaman commented Oct 29, 2025

I'm using this for birthday input. There's an important distinction:

  1. Having a default value pre-filled before user input — This means the control already contains an actual value
  2. The input value is empty, but the control displays a defaultDate value — This means the field is technically empty, just showing a hint

These are fundamentally different.

To prevent users from forgetting to enter their birthday, the field needs to be empty (no default value). We need defaultDate instead.

@probablykasper
Copy link
Owner

defaultDate might be a confusing name since it doesn't set the value itself. Internally, browseDate is what controls the date that's being browsed, so maybe it's better to expose that instead? That would also allow you to update the month shown in the picker at any time instead of just when it's opened.

Another thing to note is that defaultDate also impacts the min and max defaults

@endaaman
Copy link
Author

endaaman commented Nov 2, 2025

Good point about the naming! I see what you mean about defaultDate being confusing.

However, I'm a bit concerned that exposing browseDate directly might cause issues since it's internal state that changes during interaction.

What about renaming it to initialBrowseDate? This would:

  • Clearly indicate it only sets the initial month/year when opening the picker
  • Avoid confusion with the actual value
  • Still make sense for the min/max defaults you mentioned

If that works for you, I can update the PR. Let me know your thoughts!

@probablykasper
Copy link
Owner

That's fair, let's go with that

@endaaman
Copy link
Author

endaaman commented Nov 4, 2025

I've pushed the changes.

The CI failure is due to Codecov hitting rate limits (all tests and linting passed).
Please re-run the workflow when possible.

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.

2 participants