Skip to content

feat: add defaultSelected selection prop#2998

Draft
gpbl wants to merge 1 commit into
mainfrom
selection/default-selected
Draft

feat: add defaultSelected selection prop#2998
gpbl wants to merge 1 commit into
mainfrom
selection/default-selected

Conversation

@gpbl
Copy link
Copy Markdown
Owner

@gpbl gpbl commented May 12, 2026

Adds defaultSelected so apps can initialize uncontrolled selections without relying on selected as initial state. Keeps existing selected behavior intact for v10 compatibility; read-only controlled selections can use selected with a no-op onSelect.

What Changed

  • Added defaultSelected to single, multiple, and range selection prop types.
  • Initialized uncontrolled selection hooks from defaultSelected, falling back to existing selected behavior when omitted.
  • Normalized defaultSelected through the existing timeZone conversion path.
  • Updated selection docs, focused tests, and changeset coverage.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 12, 2026

🦋 Changeset detected

Latest commit: 00a5855

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
react-day-picker Minor
@daypicker/react Minor
@daypicker/buddhist Minor
@daypicker/ethiopic Minor
@daypicker/hebrew Minor
@daypicker/hijri Minor
@daypicker/persian Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown
Collaborator

@rodgobbi rodgobbi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gpbl IMO uncontrolled mode is not useful for DayPicker.
The consumers want to have access to the selected dates to use for something else.

Using DayPicker uncontrolled is just a calendar day picker that changes state, but that state is not used for anything else.

@gpbl
Copy link
Copy Markdown
Owner Author

gpbl commented May 17, 2026

@gpbl IMO uncontrolled mode is not useful for DayPicker. The consumers want to have access to the selected dates to use for something else.

Using DayPicker uncontrolled is just a calendar day picker that changes state, but that state is not used for anything else.

Fair point, and sorry for not providing enough context in this draft PR. The goal is to introduce the defaultSelected prop so that, in a future major release, we can address #2690.

I am still exploring the right solution here, so any feedback is very welcome!

@rodgobbi
Copy link
Copy Markdown
Collaborator

@gpbl I see, I also revisited the discussion in the issue.
Keep in mind the existing issue with undefined representing an empty selection.

What do you think of trying this together with another prop that changes the empty selection from undefined to null?

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