Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

Commit

Permalink
fix(uiSelectMultipleDirective): refresh choices upon selection change
Browse files Browse the repository at this point in the history
Closes #1243
  • Loading branch information
mshibuya committed Mar 19, 2016
1 parent 161cff5 commit 03293ff
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/uiSelectMultipleDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec
}
}
$select.selected = ngModel.$viewValue;
$selectMultiple.refreshComponent();
scope.$evalAsync(); //To force $digest
};

Expand Down
24 changes: 24 additions & 0 deletions test/select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2034,6 +2034,30 @@ describe('ui-select tests', function() {

});

it('should watch changes for $select.selected and refresh choices correctly', function () {

scope.selection.selectedMultiple = ['wladimir@email.com', 'samantha@email.com'];

var el = compileTemplate(
'<ui-select multiple ng-model="selection.selectedMultiple" theme="bootstrap" style="width: 800px;"> \
<ui-select-match placeholder="Pick one...">{{$item.name}} &lt;{{$item.email}}&gt;</ui-select-match> \
<ui-select-choices repeat="person.email as person in people | filter: $select.search"> \
<div ng-bind-html="person.name | highlight: $select.search"></div> \
<div ng-bind-html="person.email | highlight: $select.search"></div> \
</ui-select-choices> \
</ui-select> \
'
);
scope.selection.selectedMultiple.splice(0, 1); // Remove Wladimir from selection

var searchInput = el.find('.ui-select-search');
triggerKeydown(searchInput, Key.Down); //Open dropdown

expect(el.find('.ui-select-choices-content').text())
.toContain("wladimir@email.com");

});

it('should ensure the multiple selection limit is respected', function () {

scope.selection.selectedMultiple = ['wladimir@email.com'];
Expand Down

0 comments on commit 03293ff

Please sign in to comment.