angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

Form model doesn't update on autocomplete

Open msgilligan opened this issue 14 years ago • 198 comments

I'm having problems with Safari 6.0 auto-complete on some simple forms on Angular 1.0.2.

When Safari uses auto-complete to fill in the form, Angular seems to be unaware of the new characters that were entered by auto-complete.
Please see the attached image for an example.

To reproduce:

  1. Enter data into the form a few times so that auto-complete is activated.
  2. Then enter a few characters that triggers an auto-complete.
  3. Hit return.
  4. Compare the alert message with the contents of the input field.

I've created a jsFiddle that can be used to reproduce the problem: http://jsfiddle.net/msgilligan/5cynT/

I've seen a similar problem when Safari 6.0 or Chrome 22.0.1229.79 automatically fills in a password field that has a 'required' attribute. The form is not marked as valid and I have to go enter a space after the password and then delete it.

msgilligan avatar Oct 15 '12 17:10 msgilligan

Google Groups thread: http://groups.google.com/group/angular/browse_thread/thread/e8d96e712b244236

msgilligan avatar Oct 15 '12 17:10 msgilligan

A similar problem and Firefox 15.0.1

bigbag avatar Oct 17 '12 08:10 bigbag

How would you handle this? At glance it looks like the browser isn't firing change events if the form is being populated via autofill. The first thing I can think of is to run periodic checks on the form, but that sounds very suboptimal.

sudhirj avatar Nov 01 '12 14:11 sudhirj

Has anymore thought gone into this issue?

GEverding avatar Dec 05 '12 16:12 GEverding

Any insights on this one?

pgte avatar Dec 12 '12 12:12 pgte

Just banned completion. But this does not solve the problem

bigbag avatar Dec 12 '12 12:12 bigbag

+1 for effort towards some sort of solution.

davemerrill avatar Dec 13 '12 20:12 davemerrill

+1. Pls fix this

fedotxxl avatar Dec 19 '12 17:12 fedotxxl

I switch from Knockout to Angular just to find that it has the same issue with form autocompletion.

mgoku avatar Jan 01 '13 10:01 mgoku

+1 fix please. :(

scottweinert avatar Jan 11 '13 20:01 scottweinert

+1 Please fix!!!!!

shmuel613 avatar Feb 06 '13 08:02 shmuel613

+1

stryderjzw avatar Feb 19 '13 03:02 stryderjzw

+1 Please fix it :(

sophlee avatar Feb 19 '13 03:02 sophlee

Any progress? +1

lucipacurar avatar Feb 19 '13 20:02 lucipacurar

The underlying problem I think is that browsers don't (always? ever?) emit any sort of event on auto-complete, as Witold said in this thread: https://groups.google.com/forum/?fromgroups=#!topic/angular/6NlucSskQjY. Other than periodically checking the value in every field that might auto-complete, I bet this is on browser makers to fix, not Angular.

davemerrill avatar Feb 20 '13 03:02 davemerrill

Dave, I understand what you're saying, but Angular still needs to come up with an integrated solution. The reason is that form validation coupled with disabling submit buttons renders the page unusable without special controllers listening for user actions. One solution could be to re-validate the forms automatically after page load, but unfortunately, I haven't found a way to re-fire the validation that way.

shmuel613 avatar Feb 20 '13 15:02 shmuel613

I have the same issue on Chrome 25 on Win7. I found it from this issue: #1072 which also provides a temp fix.

drphrozen avatar Mar 07 '13 13:03 drphrozen

+1 Temp fix doesnt work for more complex cases (e.g. a select contains a object as model).

johannesjo avatar Mar 08 '13 17:03 johannesjo

+1... This is a very annoying issue. (Login forms should autofill. Now I can't let them be autofilled.)

RWOverdijk avatar Mar 11 '13 11:03 RWOverdijk

I would say the underlying issue is that browsers assumes the form will be submitted in the traditional manner, i.e. the field values will be read upon form submit.

The best fix I can think of is to have a method in AngularJS for reading out ng-model bound values when the form is submitted. Perhaps this could be a generic feature of scopes, such as $scope.$read(), which would be implemented so that ng-model on forms would actually read the .value when this method was called.

augustl avatar Mar 11 '13 11:03 augustl