ui-date icon indicating copy to clipboard operation
ui-date copied to clipboard

Can't select date when minDate or maxDate changes

Open dlidstrom opened this issue 11 years ago • 5 comments

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:

  1. Create a datepicker with ng-model=endDate.
  2. Create a datepicker with maxDate: endDate (same model).
  3. Either can be changed at this time, both typing and clicking.
  4. 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.

dlidstrom avatar Jun 24 '13 08:06 dlidstrom

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.

mfrancis107 avatar Jul 02 '13 19:07 mfrancis107

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.

mcarrasconearbpo avatar Jul 12 '13 22:07 mcarrasconearbpo

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);

integrate avatar Jul 17 '13 10:07 integrate

Plunkrs demonstrating the issue available on https://github.com/angular-ui/ui-date/pull/51

blowsie avatar Dec 17 '13 16:12 blowsie

Is this still relevant due to 4accb70291e288e41188a7072df59f54eb82f642

ProLoser avatar May 28 '14 06:05 ProLoser