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

refactor(choices): avoid setting activeItem on mouseenter #1211

Merged
merged 2 commits into from
Sep 29, 2015
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
5 changes: 5 additions & 0 deletions src/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
top: 0px !important;
}


.ui-select-choices-row:hover {
background-color: #f5f5f5;
}

/* Select2 theme */

/* Mark invalid Select2 */
Expand Down
1 change: 0 additions & 1 deletion src/uiSelectChoicesDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ uis.directive('uiSelectChoices',

choices.attr('ng-repeat', RepeatParser.getNgRepeatExpression($select.parserResult.itemName, '$select.items', $select.parserResult.trackByExp, groupByExp))
.attr('ng-if', '$select.open') //Prevent unnecessary watches when dropdown is closed
.attr('ng-mouseenter', '$select.setActiveItem('+$select.parserResult.itemName +')')
.attr('ng-click', '$select.select(' + $select.parserResult.itemName + ',false,$event)');

var rowsInner = element.querySelectorAll('.ui-select-choices-row-inner');
Expand Down
4 changes: 0 additions & 4 deletions src/uiSelectController.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,6 @@ uis.controller('uiSelectCtrl',
}
};

ctrl.setActiveItem = function(item) {
ctrl.activeIndex = ctrl.items.indexOf(item);
};

ctrl.isActive = function(itemScope) {
if ( !ctrl.open ) {
return false;
Expand Down
29 changes: 0 additions & 29 deletions test/select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -959,35 +959,6 @@ describe('ui-select tests', function() {

});

it('should invoke hover callback', function(){

var highlighted;
scope.onHighlightFn = function ($item) {
highlighted = $item;
};

var el = compileTemplate(
'<ui-select on-select="onSelectFn($item, $model)" ng-model="selection.selected"> \
<ui-select-match placeholder="Pick one...">{{$select.selected.name}}</ui-select-match> \
<ui-select-choices on-highlight="onHighlightFn(person)" repeat="person.name 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>'
);

expect(highlighted).toBeFalsy();

if (!isDropdownOpened(el)){
openDropdown(el);
}

$(el).find('.ui-select-choices-row div:contains("Samantha")').trigger('mouseover');
scope.$digest();

expect(highlighted).toBe(scope.people[5]);
});

it('should set $item & $model correctly when invoking callback on select and no single prop. binding', function () {

scope.onSelectFn = function ($item, $model, $label) {
Expand Down