-
Notifications
You must be signed in to change notification settings - Fork 27.5k
fix(ng-model-options): Canceling debounces now forces a view reset #7011
Conversation
Thanks for the PR! Please check the items below to help us merge this faster. See the contributing docs for more information.
If you need to make changes to your pull request, you can update the commit with Thanks again for your help! |
@@ -1701,10 +1701,13 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$ | |||
* This method should be called before directly update a debounced model from the scope in | |||
* order to prevent unintended future changes of the model value because of a delayed event. | |||
*/ | |||
this.$cancelDebounce = function() { | |||
this.$cancelDebounce = function(skipRender) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we should rename this skipReset
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I'll also document the new parameter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about skipViewValReset
to make it more explicit?
Since |
Yes you are probably right... |
Both would be right... But |
@@ -1783,6 +1786,20 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$ | |||
// model -> value | |||
var ctrl = this; | |||
|
|||
this.$resetModelValue = function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$resetView
code shares a lot with ngModelWatch
. In fact the only difference is that ngModelWatch
only updates $viewValue
and calls $render
when there is an actual change. We could add a parameter to $resetView
which could allow enabling the check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was wondering about that. Something like like forceRender
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just call this fn from ngModelWatch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ngModelWatch
is a bit different since it tests that the $modelValue
and $viewValue
actually changed (this fn is forcing it). We could add a force
param here and call this from ngModelWatch
. But I was wondering if it is even needed to re-run the $formatters
, we could just invoke $render
...
May be another name is better. What about |
I don't see why we need to re-run the |
@shahata is right. it should be enough to call Also please coordinate the effort better if possible. |
@shahata - can you join http://gitter.im |
We do need you involved in this |
This PR forces a view reset when canceling a pending debounce in order to fix some unexpected behaviors.
Closes #6994