jfmdev / ngComboDatePicker

Angular directive to select dates using combo boxes
Mozilla Public License 2.0
23 stars 20 forks source link

Model is not updated after selecting "January" #8

Closed michaelryancaputo closed 8 years ago

michaelryancaputo commented 8 years ago

I have reproduced this on the demo site, by adding the ng-required="true" flag to the field under the heading 'Place holders'. Inputting the date January 21, 1989 (the first time only) renders the input invalid even though it should be valid.

Here is an example of this behaviour: https://embed.plnkr.co/Cw8w1L81gNbNTuPCiOQy/

Have had users reproduce this issue on a variety of machines/browsers. I've taken a look at the code briefly and nothing seems out of the ordinary.

michaelryancaputo commented 8 years ago

After a bit more exploration, it seems that when the date is set to that date, the model is never updated to have any date.

michaelryancaputo commented 8 years ago

I think I resolved this with this plunkr, however i'm not sure if it's the best implementation:

https://embed.plnkr.co/bgWKBb6MfoCm7sPFPzYU/

jfmdev commented 8 years ago

Hi Michael,

Thank you for opening this issue.

The problem was caused by the month selector, i.e. the issue occurred on any date at "January".

This was because "January" was being considered an invalid month due to the sentence $scope.month != null, since in JavaScripts months are zero-based and "0" is considered equal to "null" when doing non-strict comparisons.

I have made a new release fixing this issue.
You can check your first example at this fiddle: https://jsfiddle.net/4ndhnucg/1/

Regards

michaelryancaputo commented 8 years ago

Great, yeah, that is how I resolved it in my 2nd plunkr, didnt have time to go through and test it thoroughly. Appreciate you fixing it in a new release!