Skip to content

Conversation

Harshul23
Copy link

This PR fixes the behavior of the Calendar component from the shadcn/ui library (https://ui.shadcn.com/docs/components/calendar), specifically based on the Date of Birth Picker example.

Issue:
After selecting a date of birth, the selected date appeared correctly in the input field. However, when reopening the calendar to change the date, the calendar always opened on the current date instead of the previously selected date.

Solution:

  • Updated the calendar logic to retain and display the previously selected date when reopening the calendar.
   <Calendar
  mode="single"
  selected={date}
  onSelect={setDate}
  defaultMonth={date} // Added this line
  className="rounded-md border shadow-sm"
  captionLayout="dropdown"/>
  • Ensured consistent behavior across different scenarios and input changes.
  • Verified functionality in the Date of Birth Picker example.

Closes #8243.

Copy link

vercel bot commented Oct 15, 2025

@Harshul23 is attempting to deploy a commit to the shadcn-pro Team on Vercel.

A member of the Team first needs to authorize it.

@Harshul23 Harshul23 force-pushed the fix/calendar-defaultMonth branch from f6fe5b6 to 7a3f5d5 Compare October 15, 2025 10:19
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.

[feat]: Preserve date on Calendar in case you have selected a date

1 participant