nazar-pc / PickMeUp

Really simple, powerful, customizable and lightweight standalone datepicker
BSD Zero Clause License
615 stars 191 forks source link

default_date false results in default selection of today #158

Open dgrant85 opened 7 years ago

dgrant85 commented 7 years ago

Docs state that setting default_date option to false will "keep empty value until date selected"

Expected behaviour: datepicker will have no default date selection Actual result: today's date is selected by default

Codepen: http://codepen.io/anon/pen/pRyKgX

nazar-pc commented 7 years ago

This behavior might not be described perfectly, it is actually used in conjunction with input element, when you want to keep input field empty until user selects date.

dgrant85 commented 7 years ago

Ah, ok. Thanks. Is there any way to have the datepicker without a default selection on load?

I can see we already have a class for pmu-today , it would be to essentially clear .pmu-selected, until a selection is made by the user.

nazar-pc commented 7 years ago

You can always apply custom logic for showing which dates are selected by using https://github.com/nazar-pc/PickMeUp#selectingdisabling-dates-with-custom-logic I think it might be better to also respect default_date: false here as well, so I'll turn this into enhancement. Feel free to send a PR.

dgrant85 commented 7 years ago

Got you, i've tried setting selected: false within the render callback however this doesn't appear to be working. Disabled works to disable the current date however today's date still holds the class pmu-selected.

Am I approaching this wrong? - CP updated : http://codepen.io/anon/pen/pRyKgX

nazar-pc commented 7 years ago

It only worked with true and ignored false. Should be fixed in b17664a: https://codepen.io/anon/pen/Lxxvgg

dgrant85 commented 7 years ago

Thanks can see this working. I think i've misinterpreted its function as setting false within the render callback would permanently prevent selection of that date.

I think as you suggest, it may be best to respect default_date: false here, preventing a default date selection, but allowing for a selection to be made by the user.

Essentially the use-case is that there are several instances in which one would want a datepicker without any default date selected, but allowing a user to select any date from it.