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

bug(ngModel): $setViewValue doesn't call $$debounceViewValue when called with the appropriate trigger #14886

Open
gkalpak opened this issue Jul 8, 2016 · 3 comments

Comments

@gkalpak
Copy link
Member

gkalpak commented Jul 8, 2016

Do you want to request a feature or report a bug?
Bug.

What is the current behavior?
Calling NgModelController#$setViewValue(value, trigger) will call $$debounceViewValue() only if there is no ngModelOptions or ngModelOptions#updateOnDefault is true.
See here.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (template: http://plnkr.co/edit/tpl:yBpEi4).
Demo
Clicking both buttons, I would expect both NgModelControllers to get updated.
The one with {updateOn: 'blur'} doesn't 😞

What is the expected behavior?
Calling NgModelController#$setViewValue(value, trigger) will also call $$debounceViewValue() if ngModelOptions#updateOn includes trigger.

What is the motivation / use case for changing the behavior?
To make it work as expected 😁

Which versions of Angular, and which browser / OS are affected by this issue? Did this work in previous versions of Angular? Please also test with the latest stable and snapshot (https://code.angularjs.org/snapshot/) versions.
Only tried on 1.5.7, but it should affect many versions back.

Other information (e.g. stacktraces, related issues, suggestions how to fix)
No 😕

@petebacondarwin
Copy link
Member

That definitely doesn't seem quite right. What is weird is that if you click the second then the first button, all four are updated!

@gkalpak
Copy link
Member Author

gkalpak commented Jul 10, 2016

The reason it works if you press the first button after you have pressed the second one, is because of the digest that get triggered by the button click. There is an ngModel watch-action executed per digest, that will sync the values (see here).

The problem is when this happens outside of a digest. And even from inside a digest, the values are not updated synchronously as happens in the first case (with updateOnDefault === true).

@gkalpak
Copy link
Member Author

gkalpak commented Jul 10, 2016

BTW, this was a by-product of a discussion with @jeserkin on gitter and he expressed interest in taking a stab at it. (Shamelessly) saving it for him 😛

@petebacondarwin petebacondarwin modified the milestones: Backlog, Backlog2 Oct 17, 2016
@Narretz Narretz self-assigned this Nov 20, 2017
Narretz added a commit to Narretz/angular.js that referenced this issue Nov 21, 2017
@Narretz Narretz removed their assignment Jan 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants