ui-date
ui-date copied to clipboard
Can't select date when minDate or maxDate changes
I have two datepickers, one is used to limit the range of the other (using a model and maxDate). When the independent one changes, I can no longer change the value of the dependent one by using the mouse. It is still possible to type a value in the dependent datepicker, but using the mouse is not possible (the value simply doesn't change).
To recreate:
- Create a datepicker with ng-model=endDate.
- Create a datepicker with maxDate: endDate (same model).
- Either can be changed at this time, both typing and clicking.
- But, when the one from step 1 is changed, the second one can't be changed anymore by using the mouse. It seems like the on-blur function is being called too often (or at the wrong time). The function is setting the value to the old value, thereby preventing the datepicker from changing at all. Typing works fine, strangely enough.
I hope this is understandable. If not, I can try to create a plnkr.
This appears to be an issue when changing any of the options for your datepicker. Tested by changing the nextText. It changed the text but couldn't select a date afterwards.
I have the same issue, I replaced line 48: element.on('blur', function() { with element.on('click', function() {
and that worked for me, but I don't know if this hack is the right way to fix this bug or if it can cause other undesired side effects.
I got same issue. I resolved it in this way:
Find string "scope.$watch(getOptions, initDateWidget, true);" Delete or comment it. Insert this code instead:
scope.$watch(getOptions, function(newOpts)
{
if (element.hasClass('hasDatepicker')){
element.datepicker('option', newOpts);
}
else
{
initDateWidget();
}
}, true);
Plunkrs demonstrating the issue available on https://github.com/angular-ui/ui-date/pull/51
Is this still relevant due to 4accb70291e288e41188a7072df59f54eb82f642