reagent-project / reagent-forms

Bootstrap form components for Reagent
339 stars 78 forks source link

Datepicker year selection stops working when previous/next month arrow is clicked #85

Closed raboui closed 8 years ago

raboui commented 8 years ago

The following script error occurs when attempting to select a year from the datepicker. Uncaught Error: No item 2 in vector of length 2

The problem only seems to occur when:

  1. A user opens the datepicker
  2. Selects the previous or next month arrow
  3. Drill down to a decade year range
  4. Attempt to select a year. Nothing happens and error is logged.

The only way to get the datepicker to work again is to reload the page This behaviour also occurs on the reagent-forms examples page.

yogthos commented 8 years ago

Yeah looks like there's an out of bounds edge case here, any chance you'd be interested in looking into this? I probably won't get to it for a little while.

raboui commented 8 years ago

Had a look and put in a fix for the issue, however as I was testing found another bug.

  1. Select 31st March from datepicker.
  2. Drill down to the month view and select February.
  3. Close the datepicker without selecting a date.

On the examples page this currently sets a date of 2016/02/0. In the version with the fix for this issue date appears as 2015/02/31 which is also incorrect.

Thoughts on how this should behave? Maybe disable setting of date in the input field until a day has been selected. This is similar to the bootstrap datepicker. https://eonasdan.github.io/bootstrap-datetimepicker/

yogthos commented 8 years ago

Yeah, I think that would be a reasonable solution here. Thanks for digging into this by the way.