Skip to content
This repository has been archived by the owner on May 28, 2019. It is now read-only.

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

Open
somewhatabstract opened this issue Nov 4, 2016 · 0 comments
Open

Comments

@somewhatabstract
Copy link

somewhatabstract commented Nov 4, 2016

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant