Skip to content
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

Today's button delete the date value #873

Closed
jlemale opened this issue Mar 30, 2014 · 8 comments
Closed

Today's button delete the date value #873

jlemale opened this issue Mar 30, 2014 · 8 comments

Comments

@jlemale
Copy link

jlemale commented Mar 30, 2014

With the parameter todayBtn: "linked"
if you click on Today, it displays the current day BUT if it's already the current day or if you click twice on Today it deletes everything. I think it shouldn't do that.

You can reproduce it on the official demo :
http://eternicode.github.io/bootstrap-datepicker/?markup=input&format=&weekStart=&startDate=&endDate=&startView=0&minViewMode=0&todayBtn=false&language=en&orientation=auto&multidate=&multidateSeparator=&keyboardNavigation=on&forceParse=on#sandbox

@alberteddu
Copy link

I agree.

On a side note, this happens even if you don't click on today, or if todayBtn is not set to "linked". When clicking on a day, if that day is already selected, the selection is toggled. This makes more sense if the datepicker is not set to autoclose, because you may want to toggle the selection by clicking on the same day. But, for example, when the datepicker closes itself, it's not the best behavior.

Maybe it would be useful to add an option?

@dittodhole
Copy link

i've implemented an option disableDateToggle to work as suggested.

@alberteddu
Copy link

Thanks @dittodhole!

@sarus
Copy link

sarus commented Apr 25, 2014

This same issue means that when you type the date into the input (click on the input then start typing instead of using the calendar UI) and press enter, the date gets cleared (I can't think of any rationale for this to happen) and feels more like a bug than a feature.

Note that the commit 73da54b fixes the problem where typing the date and pressing enter causes the date to get deleted.

@dittodhole
Copy link

The simple reason is, that this component provides toggling of dates - which comes in handy when in multi-date-mode: I click on Monday, Tuesday, then I say "well, Monday was wrong" and click on Monday again and it gets cleared.

And in single-date-mode there are ways to "double click" too:

  • type the date and click (each keydown triggers a parsing, which might set the value)
  • type the date and enter (see above)
  • double clicking on a date (when autoclose is set to false or reopening the dialog)

I've simply provided an option-property disableDateToggle to override this feature.

Someone, someday might think of a better way (eg natural behavior) for disabling the toggling (as mentioned before: does toggling in single-date-mode make sense?)

@martijn80
Copy link

Thanks @dittodhole!

@k0chalit0
Copy link

Thanks @dittodhole needed this

@acrobat
Copy link
Member

acrobat commented Dec 29, 2014

The "clear" toggle was fixed in #843

@acrobat acrobat closed this as completed Dec 29, 2014
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

No branches or pull requests

7 participants