Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
fix(select): multiple no longer sets form to $dirty
Browse files Browse the repository at this point in the history
closes #3933
  • Loading branch information
rschmukler committed Sep 21, 2015
1 parent 9313a4a commit 09bd5a3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/components/select/select.js
Expand Up @@ -184,6 +184,12 @@ function SelectDirective($mdSelect, $mdUtil, $mdTheming, $mdAria, $compile, $par
}
}

if (formCtrl) {
$mdUtil.nextTick(function() {
formCtrl.$setPristine();
});
}

var originalRender = ngModelCtrl.$render;
ngModelCtrl.$render = function() {
originalRender();
Expand Down Expand Up @@ -489,6 +495,7 @@ function SelectMenuDirective($parse, $mdUtil, $mdTheming) {
// reference. This allowed the developer to also push and pop from their array.
$scope.$watchCollection($attrs.ngModel, function(value) {
if (validateArray(value)) renderMultiple(value);
self.ngModel.$setPristine();
});
} else {
delete ngModel.$validators['md-multiple'];
Expand Down

1 comment on commit 09bd5a3

@GoodCoding
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

This fix sets the form pristine on every dropdown loading, not only fixing the multiple select problem.
If the form is outside the changing ui router views you don't have the chance of detecting changes by
checking ng-dirty.

Is there a chance that the $setPristine() is only executed within the scenario of loading the multi-select?

Best Regards,

Good Coding

Please sign in to comment.