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

fix(uiSelectChoices) broken id interpolation #1533

Merged
merged 1 commit into from
Mar 29, 2016
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
2 changes: 1 addition & 1 deletion src/bootstrap/choices.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<li class="ui-select-choices-group" id="ui-select-choices-{{ $select.generatedId }}" >
<div class="divider" ng-show="$select.isGrouped && $index > 0"></div>
<div ng-show="$select.isGrouped" class="ui-select-choices-group-label dropdown-header" ng-bind="$group.name"></div>
<div id="ui-select-choices-row-{{ $select.generatedId }}-{{$index}}" class="ui-select-choices-row"
<div ng-attr-id="ui-select-choices-row-{{ $select.generatedId }}-{{$index}}" class="ui-select-choices-row"
ng-class="{active: $select.isActive(this), disabled: $select.isDisabled(this)}" role="option">
<a href="" class="ui-select-choices-row-inner"></a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/select2/choices.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div ng-show="$select.choiceGrouped($group)" class="ui-select-choices-group-label select2-result-label" ng-bind="$group.name"></div>
<ul role="listbox"
id="ui-select-choices-{{ $select.generatedId }}" ng-class="{'select2-result-sub': $select.choiceGrouped($group), 'select2-result-single': !$select.choiceGrouped($group) }">
<li role="option" id="ui-select-choices-row-{{ $select.generatedId }}-{{$index}}" class="ui-select-choices-row" ng-class="{'select2-highlighted': $select.isActive(this), 'select2-disabled': $select.isDisabled(this)}">
<li role="option" ng-attr-id="ui-select-choices-row-{{ $select.generatedId }}-{{$index}}" class="ui-select-choices-row" ng-class="{'select2-highlighted': $select.isActive(this), 'select2-disabled': $select.isDisabled(this)}">
<div class="select2-result-label ui-select-choices-row-inner"></div>
</li>
</ul>
Expand Down
17 changes: 17 additions & 0 deletions test/select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,23 @@ describe('ui-select tests', function() {
expect(getMatchLabel(el)).toEqual('Samantha');
});

it('should correctly render initial state with track by $index', function () {

var el = compileTemplate(
'<ui-select ng-model="selection.selected"> \
<ui-select-match placeholder="Pick one...">{{$select.selected.name}}</ui-select-match> \
<ui-select-choices repeat="person in people track by $index"> \
{{person.email}} \
</ui-select-choices> \
</ui-select>'
);

openDropdown(el);

var generatedId = el.scope().$select.generatedId;
expect($(el).find('[id="ui-select-choices-row-' + generatedId + '-0"]').length).toEqual(1);
});

it('should utilize wrapper directive ng-model', function() {
var el = compileTemplate('<wrapper-ui-select ng-model="selection.selected"/>');
scope.selection.selected = { name: 'Samantha', email: 'something different than array source', group: 'bar', age: 30 };
Expand Down