Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

datepicker: does not reset $modelValue to null when invalid - this means ng-change doesn't fire either #10231

Closed
@johnjesse

Description

@johnjesse

Actual Behavior:

  • What is the issue? *

the datepicker does not reset the $modelValue to null when the input is invalid. I think this is because it uses $setValidity instead of registering validators. Importantly this is opposite to how angular normally behaves.

As it doesn't reset the model value then ng-change events don't fire, normally they do fire when you move form a valid to an invalid modelValue.

  • What is the expected behavior?

The $modelValue should be set to null

CodePen (or steps to reproduce the issue): *

  • CodePen Demo which shows your issue:

http://codepen.io/anon/pen/OWVbNP

  • Details:

enter a valid date e.g. 1/1/1 - the model value updates accordingly
change date to invalid e.g. 2001/20001/20001 - the model value stays the same as it was before

compare this to the input box

enter a valid number e.g. 1 - the model value is 1
change to an invalid number e.g. -1 - the model value is reset to null

Angular Versions: *

  • Angular Version:1.5.8
  • Angular Material Version:1.1.1

Additional Information:

  • Browser Type: * Chrome
  • Browser Version: *
  • OS: * Windows
  • Stack Traces:

Shortcut to create a new CodePen Demo.
Note: * indicates required information. Without this information, your issue may be auto-closed.

Do not modify the titles or questions. Simply add your responses to the ends of the questions.
Add more lines if needed.

Metadata

Metadata

Assignees

Labels

resolution: too riskyThere is too much risk or disruption with this proposal for our limited resources.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions