slider: position does not update correctly when both bound value and bound max are changed #9125
Comments
I encountered this recently myself, and have a theory as to what exactly is going on: When both the bound value and the bound max are changed in the same digest cycle, the value is updated first, such that min <= value <= max. Then the max is updated. If the bound value is increased above the old max value, it will be capped at that. You can see this in the plunk linked above, where changing "Half value" from 2 to 3 will leave the slider displaying 5, the max when half-value is 2. (It should display 6.) Doing the changes in different digest cycles (max first, then value) avoids the problem. That's why the $timeout workaround works. |
Slider, which occurred when both model and either min and/or max values were updated within the same digest cycle. This is due to the $ngModelCtrl formatters kicking in and validating the view value before the Slider directive $observer on the min and max attributes could fire. Fixes angular#9125
I reviewed the PR. If we can get the minor updates made soon, then this should be able to get into the next release. |
…igest cycle Fix out of sync state between model and view value that occurs in Slider when both model and either min and/or max values are updated within the same digest cycle. This is due to the $ngModelCtrl formatters kicking in and validating the view value before the Slider directive $observer on the min and max attributes can fire. Fixes angular#9125
…igest cycle (#10980) Fix out of sync state between model and view value that occurs in Slider when both model and either min and/or max values are updated within the same digest cycle. This is due to the $ngModelCtrl formatters kicking in and validating the view value before the Slider directive $observer on the min and max attributes can fire. Fixes #9125
…igest cycle (angular#10980) Fix out of sync state between model and view value that occurs in Slider when both model and either min and/or max values are updated within the same digest cycle. This is due to the $ngModelCtrl formatters kicking in and validating the view value before the Slider directive $observer on the min and max attributes can fire. Fixes angular#9125
…igest cycle (#10980) Fix out of sync state between model and view value that occurs in Slider when both model and either min and/or max values are updated within the same digest cycle. This is due to the $ngModelCtrl formatters kicking in and validating the view value before the Slider directive $observer on the min and max attributes can fire. Fixes #9125
Actual Behavior:
What is the issue? *
When I change both the bound value in an md-slider and the bound maximum, the slider position is not always updated correctly. When both value and max are increased, the position is incorrect until the value is changed again. However, when both are decreased, it seems to work ok.What is the expected behavior?
The slider position should be correct according to both the new value and the new maximum.CodePen (or steps to reproduce the issue): *
CodePen Demo which shows your issue:
Please see this Plunk.Details:
Change "Half value" from 2 to 3 as described in the HTML and observe the position change in the slider. Compare the position to what is obtained by changing the value alone with the numerical input.Angular Versions: *
Angular Version:
1.5.3Angular Material Version:
1.1.0-rc4Additional Information:
Browser Type: *
Google ChromeBrowser Version: *
51.0.2704.103 mOS: *
Windows 8.1 x64Stack Traces:
N/AThe text was updated successfully, but these errors were encountered: