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

viewDate does not stick #221

Open
moveson opened this issue Dec 6, 2018 · 0 comments
Open

viewDate does not stick #221

moveson opened this issue Dec 6, 2018 · 0 comments

Comments

@moveson
Copy link

moveson commented Dec 6, 2018

For a birthdate-style datepicker, the most convenient solution seems to be to set the viewMode to decades and the viewDate to January 1, 1900, like so:

$('[id^="datepicker"]').datetimepicker({
  format: 'L',
  viewMode: 'decades',
  viewDate: moment('1900-01-01'),
  useCurrent: false
});

This works as expected the first time the user clicks on the toggle icon. The user is shown every decade from 1900s to 2000s, making an easy entry point without having to click the left or right buttons.

But if the user closes the picker without picking a date, viewDate is reset to the current time. So the next time the user opens the picker, the viewMode is still decades, but now the view shows decades from 1990 through 2100.

This change violates the principle of least surprise. Instead, viewDate should remain set unless a date is actually selected from the picker.

Also, this is only tangentially related, but viewDate is not documented at all.

ouija added a commit to ouija/tempusdominus-bootstrap-4 that referenced this issue Oct 8, 2020
ouija added a commit to ouija/tempusdominus-bootstrap-4 that referenced this issue Oct 8, 2020
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

1 participant