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

Picker shows wrong month calendar. #48

Open
imbens opened this issue May 31, 2017 · 0 comments
Open

Picker shows wrong month calendar. #48

imbens opened this issue May 31, 2017 · 0 comments
Labels

Comments

@imbens
Copy link

imbens commented May 31, 2017

Steps to reproduce:

  1. Wait until the 31st of a month (eg. today) whose successor has less than 31 days.
  2. Open the demo link: https://brianblakely.github.io/nodep-date-input-polyfill/
  3. Click on the first field.
  4. Select the next month.
    The month selector will show the next month, but the picker will show a calendar for the month after that.

This is caused by the following code in picker.js:
this.month.addEventListener(change, ()=> { this.date.setMonth(this.month.value); this.refreshDaysMatrix(); });
setMonth will update the month, but the next month has only 30 days. The Date object will now represent the first of the month after the next month.
An easy fix is:
this.month.addEventListener(change, ()=> { this.date.setMonth(this.month.value, 1); this.refreshDaysMatrix(); });
This makes sure that setMonth sets the Date object to the first of the next month. See also https://stackoverflow.com/questions/14680396/the-date-getmonth-method-has-bug
Apparently the problem does not happen in Chrome. It does happen in Safari.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants