-
-
Notifications
You must be signed in to change notification settings - Fork 421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DatePicker component defaultDate/clear not working as expected #1039
Comments
Well, I guess that the Datepicker references that I got were always displaying the "today" date as default. So... It is kind of, not a bug, 'cause it is working as it was programmed to do... but, got it... I guess that makes sense to level it empty sometimes. |
Hey @rluders , thank you for the quick response! I did have to switch to react-datepicker for the time being until this gets resolved. The way they do it is with a isClearable props, once you set it to true, you can clear out the field and assign null/undefined values. ... just a food for thought |
so if you pass a defaultDate prop then the DatePicker should render with that date selected? Is that the expected behavior? if so i am having this issue as well |
…r clicking clear button" A new optional property with a default value was added to the component definition to define what text the developer wants to use when the datepicker component has its date cleared ( which means no date selected ). themesberg#1039 themesberg#1167
One workaround for controlled Datepicker is that you can set const emptyProps = !value
? {
value: "",
placeholder: "Please select a date",
}
: {};
<Datepicker {...emptyProps } /> The But yeah, the Datepicker will still have its internal value. |
A isClear callback will be nice to set the date to null|undefined In my case I will add a datepicker that is not mandatory to fill |
Steps to reproduce
Create a default DatePicker component.
Current behavior
Component renders with today's date as the selected one, additionally, clearing out the date sets the selected date to today.
Expected behavior
Component input should be empty. Ideally, placeholder should be displayed if passed in.
The text was updated successfully, but these errors were encountered: