Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit 2731f10

Browse files
author
Robert Messerle
committed
fix(autocomplete): clicking on the scrollbar in the dropdown will no longer cause the list to hide
Closes #1739.
1 parent cf78ba9 commit 2731f10

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/components/autocomplete/js/autocompleteController.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
input: $element[0].getElementsByTagName('input')[0]
1717
},
1818
promise = null,
19-
cache = {};
19+
cache = {},
20+
noBlur = false;
2021

2122
//-- public variables
2223
self.scope = $scope;
@@ -34,6 +35,11 @@
3435
self.fetch = $mdUtil.debounce(fetchResults);
3536
self.messages = [];
3637

38+
//-- While the mouse is inside of the dropdown, we don't want to handle input blur
39+
//-- This is to allow the user to scroll the list without causing it to hide
40+
self.listEnter = function () { noBlur = true; };
41+
self.listLeave = function () { noBlur = false; };
42+
3743
return init();
3844

3945
//-- start method definitions
@@ -129,7 +135,7 @@
129135
}
130136

131137
function blur () {
132-
self.hidden = true;
138+
if (!noBlur) self.hidden = true;
133139
}
134140

135141
function keydown (event) {

src/components/autocomplete/js/autocompleteDirective.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@
6363
ng-if="$mdAutocompleteCtrl.loading"\
6464
md-mode="indeterminate"></md-progress-linear>\
6565
</md-autocomplete-wrap>\
66-
<ul role="presentation">\
66+
<ul role="presentation"\
67+
ng-mouseenter="$mdAutocompleteCtrl.listEnter()"\
68+
ng-mouseleave="$mdAutocompleteCtrl.listLeave()">\
6769
<li ng-repeat="(index, item) in $mdAutocompleteCtrl.matches"\
6870
ng-class="{ selected: index === $mdAutocompleteCtrl.index }"\
6971
ng-show="searchText && !$mdAutocompleteCtrl.hidden"\

0 commit comments

Comments
 (0)