Skip to content

Commit 6fe827a

Browse files
committed
1 parent 3843e0d commit 6fe827a

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

src/select.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,10 @@
167167
var ctrl = this;
168168

169169
var EMPTY_SEARCH = '';
170+
var scrollFlag = false; //marks if the 'mouseover' event is triggered by the _ensureHighlightVisible function call which controls the scrolling. stopPropagation if so
170171

171-
ctrl.placeholder = undefined;
172+
173+
ctrl.placeholder = undefined;
172174
ctrl.search = EMPTY_SEARCH;
173175
ctrl.activeIndex = 0;
174176
ctrl.activeMatchIndex = -1;
@@ -195,6 +197,8 @@
195197
};
196198

197199
var _searchInput = $element.querySelectorAll('input.ui-select-search');
200+
var dropdownEle = _searchInput[0].parentNode;
201+
198202
if (_searchInput.length !== 1) {
199203
throw uiSelectMinErr('searchInput', "Expected 1 input.ui-select-search but got '{0}'.", _searchInput.length);
200204
}
@@ -787,18 +791,27 @@
787791
}
788792
});
789793

790-
_searchInput.on('tagged', function() {
791-
$timeout(function() {
794+
_searchInput.on('tagged', function () {
795+
$timeout(function () {
792796
_resetSearchInput();
793797
});
794798
});
795799

796-
_searchInput.on('blur', function() {
797-
$timeout(function() {
800+
_searchInput.on('blur', function () {
801+
$timeout(function () {
798802
ctrl.activeMatchIndex = -1;
799803
});
800804
});
801805

806+
// capture the mouseover event before it propagates to child nodes
807+
dropdownEle.addEventListener('mouseover', function (e) {
808+
if (scrollFlag) {
809+
e.preventDefault();
810+
e.stopPropagation();
811+
}
812+
scrollFlag = false;
813+
}, true);
814+
802815
function _findCaseInsensitiveDupe(arr) {
803816
if ( arr === undefined || ctrl.search === undefined ) {
804817
return false;
@@ -854,8 +867,10 @@
854867
var height = container[0].offsetHeight;
855868

856869
if (posY > height) {
870+
scrollFlag = true;
857871
container[0].scrollTop += posY - height;
858872
} else if (posY < highlighted.clientHeight) {
873+
scrollFlag = true;
859874
if (ctrl.isGrouped && ctrl.activeIndex === 0)
860875
container[0].scrollTop = 0; //To make group header visible when going all the way up
861876
else
@@ -1235,7 +1250,8 @@
12351250

12361251
choices.attr('ng-repeat', RepeatParser.getNgRepeatExpression($select.parserResult.itemName, '$select.items', $select.parserResult.trackByExp, groupByExp))
12371252
.attr('ng-if', '$select.open') //Prevent unnecessary watches when dropdown is closed
1238-
.attr('ng-mouseenter', '$select.setActiveItem('+$select.parserResult.itemName +')')
1253+
// change ng-mouseenter to ng-mouseover because 'mouseenter' event does not bubble and cannot be captured by parent node
1254+
.attr('ng-mouseover', '$select.setActiveItem('+$select.parserResult.itemName +')')
12391255
.attr('ng-click', '$select.select(' + $select.parserResult.itemName + ',false,$event)');
12401256

12411257
var rowsInner = element.querySelectorAll('.ui-select-choices-row-inner');

0 commit comments

Comments
 (0)