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

Hitting enter on bad string doesn't update it to a real date

Open somewhatabstract opened this issue 10 years ago • 0 comments

Problem

Version: 1.1.1 Enter a date into a field such as 11/4/2016 and tab away or otherwise blur the control. Then edit it again and enter something like 1/1, something that isn't a valid date on its own. Rather than change to 1/1/2016 or today's date, the 1/1 remains, the input loses focus and the calendar dropdown still remains visible. This leads to an invalid date being submitted in the form but I cannot seem to get validation to show it as invalid. This leads to null reaching my controller instead of a date.

Expectation

I would expect the same behavior as tabbing or clicking away; the value would be validated and either turned into a valid date or a validation error appearing.

Reproduce

Just go to the ui-date demo page and repeat the steps. It exhibits the problem.

https://angular-ui.github.io/ui-date/

In the very first datepicker on that screen, enter 1.1 and hit enter.

Suspicions

I've poked through the code a bit and I think this has something to do with how the onSelect operates when enter is hit. It should probably be calling setDate on the datepicker and not just setViewValue which doesn't appear to be working.

somewhatabstract avatar Nov 04 '16 19:11 somewhatabstract