gpbl / react-day-picker

DayPicker is a customizable date picker component for React. Add date pickers, calendars, and date inputs to your web applications.

Home Page:https://daypicker.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Calendar set's date to undefined when same date selected and this give inconsistent behavior!

Hussseinkizz opened this issue · comments

The Problem

Apparently what the calendar provides on select is inconsistent, it can be date or undefined, and when using the format to format this given date, it raises an error as the format function can't format an undefined date.
The undefined date is given if the same date is selected twice, that is if previous selected date is same as new selected date!

Expected Behavior

we can select any date any given number of times without issues provided it's not disabled!

For more context

I first opened this issue on shadcn UI repo, you can see it here and the hacky way I went over with for now, see Issue: shadcn-ui/ui#2857

Hi @Hussseinkizz

If I understand correctly, you are referring to the behavior that , when clicking a selected date, this becomes unselected. This is by design.

To make a date always selected, use the required prop.

https://react-day-picker.js.org/basics/selecting-days#making-a-selection-required

Am not really sure if it's that, would that cause the value given by onselect to be undefined when same date is re-selected?