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

fix: fixes the mouse activation issue #2160 #2161

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
18 changes: 18 additions & 0 deletions src/uiSelectChoicesDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,22 @@ uis.directive('uiSelectChoices',

return function link(scope, element, attrs, $select) {

var lastIndex = -1;
function mouseActivationHandler(ev) {
var row = angular.element(ev.target).closest('.ui-select-choices-row');
if (row) {
var rowScope = row.scope();
if (rowScope && angular.isDefined(rowScope.$index)) {
var newIndex = rowScope.$index;
if (newIndex !== lastIndex) {
lastIndex = newIndex;
scope.$apply(function() {
$select.activeIndex = newIndex;
});
}
}
}
}

$select.parseRepeatAttr(attrs.repeat, groupByExp, groupFilterExp); //Result ready at $select.parserResult
$select.disableChoiceExpression = attrs.uiDisableChoice;
Expand Down Expand Up @@ -80,8 +96,10 @@ uis.directive('uiSelectChoices',
if (open) {
tElement.attr('role', 'listbox');
$select.refresh(attrs.refresh);
element.on('mousemove', mouseActivationHandler);
} else {
element.removeAttr('role');
element.off('mousemove', mouseActivationHandler);
}
});
};
Expand Down