nodep-date-input-polyfill icon indicating copy to clipboard operation
nodep-date-input-polyfill copied to clipboard

Picker shows wrong month calendar.

Open imbens opened this issue 7 years ago • 0 comments

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.

imbens avatar May 31 '17 14:05 imbens