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

fix(uiSelectMultipleDirective): refresh choices upon selection change #1508

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = ['[email protected]', '[email protected]'];

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("[email protected]");

});

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

scope.selection.selectedMultiple = ['[email protected]'];
Expand Down