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

Input[type=email] is not reset on model reset #10027

Open
@martinczerwi

Description

@martinczerwi

There's a bug with updating view values when an input of type email contains invalid content and its model is an objects' property.

A practical example is resetting an object using angular.copy with an empty object, like it's done in most examples in the Developer Guide, Chapter "Forms" (https://docs.angularjs.org/guide/forms).

I've created a plunk with simple instructions, which demonstrate the bug: http://plnkr.co/edit/cJgs2Nji79hxF1m5doRM?p=preview

The reason this happens, is that email inputs don't get their model values updated, if the content is invalid. Later when a model change happens, NgModelController determines the value via ngModelGet($scope); and compares this to ctrl.$modelValue (see this line:

if (modelValue !== ctrl.$modelValue) {
).

Both are undefined, in case you didn't enter any valid input before, and therefore the view value is not updated.

If noticed ctrl.$dirty is set to true, on the line above, so a simple fix could be to also ask if $dirty is true. But I can't estimate the performance hit, and can't help with tests as I'm still pretty new to angular internals.

Please help and verify, or tell me if I got something wrong.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions