Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 28, 2019. It is now read-only.
This repository was 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

@somewhatabstract

Description

@somewhatabstract

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions