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

Commit 8b79674

Browse files
committed
Merge pull request #1508 from mshibuya/refresh-choices-on-selection-change
fix(uiSelectMultipleDirective): refresh choices upon selection change Closes #1243
2 parents 1a80bf1 + 03293ff commit 8b79674

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

Diff for: src/uiSelectMultipleDirective.js

+1
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ uis.directive('uiSelectMultiple', ['uiSelectMinErr','$timeout', function(uiSelec
162162
}
163163
}
164164
$select.selected = ngModel.$viewValue;
165+
$selectMultiple.refreshComponent();
165166
scope.$evalAsync(); //To force $digest
166167
};
167168

Diff for: test/select.spec.js

+24
Original file line numberDiff line numberDiff line change
@@ -2034,6 +2034,30 @@ describe('ui-select tests', function() {
20342034

20352035
});
20362036

2037+
it('should watch changes for $select.selected and refresh choices correctly', function () {
2038+
2039+
scope.selection.selectedMultiple = ['[email protected]', '[email protected]'];
2040+
2041+
var el = compileTemplate(
2042+
'<ui-select multiple ng-model="selection.selectedMultiple" theme="bootstrap" style="width: 800px;"> \
2043+
<ui-select-match placeholder="Pick one...">{{$item.name}} &lt;{{$item.email}}&gt;</ui-select-match> \
2044+
<ui-select-choices repeat="person.email as person in people | filter: $select.search"> \
2045+
<div ng-bind-html="person.name | highlight: $select.search"></div> \
2046+
<div ng-bind-html="person.email | highlight: $select.search"></div> \
2047+
</ui-select-choices> \
2048+
</ui-select> \
2049+
'
2050+
);
2051+
scope.selection.selectedMultiple.splice(0, 1); // Remove Wladimir from selection
2052+
2053+
var searchInput = el.find('.ui-select-search');
2054+
triggerKeydown(searchInput, Key.Down); //Open dropdown
2055+
2056+
expect(el.find('.ui-select-choices-content').text())
2057+
.toContain("[email protected]");
2058+
2059+
});
2060+
20372061
it('should ensure the multiple selection limit is respected', function () {
20382062

20392063
scope.selection.selectedMultiple = ['[email protected]'];

0 commit comments

Comments
 (0)