reagent-project / reagent-forms

Bootstrap form components for Reagent

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

raboui opened this issue · comments

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.

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.

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/

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