Skip to content

Commit 9f0035c

Browse files
committed
Revert "fix an existing issue: angular-ui/ui-select#282"
This reverts commit 43a924b.
1 parent 43a924b commit 9f0035c

File tree

3 files changed

+24
-36
lines changed

3 files changed

+24
-36
lines changed

app/scripts/directives/dropdown-items.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

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

4545
var rowsInner = element.querySelectorAll('.acq-dropdown-item-row-inner');
@@ -49,15 +49,13 @@
4949

5050
$compile(element, transcludeFn)(scope); //Passing current transcludeFn to be able to append elements correctly from uisTranscludeAppend
5151

52-
// not the same element after compile?
53-
// element.querySelectorAll('.acq-dropdown-item-row').on('mouseover', function(){
54-
// console.log('choice row mouseenter triggered');
55-
// });
56-
57-
// element.on('mouseover', function(){
58-
// console.log('dropdown-item mouseover triggered');
59-
// });
52+
scope.$on('$destroy', function(){
53+
console.log('dropdown-item directive scope destroy');
54+
});
6055

56+
element.on('$destroy', function(){
57+
console.log('dropdow-item directive element destroy');
58+
});
6159
// scope.$watch('$select.search', function(newValue) {
6260
// if(newValue && !$select.open && $select.multiple) $select.activate(false, true);
6361
// // $select.activeIndex = $select.tagging.isActivated ? -1 : 0;

app/scripts/directives/dropdown-list.js

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
var ngModel = ctrls[1];
3333

3434
var searchInput = element.querySelectorAll('input.ui-select-search');
35-
var scrollFlag = false; // marks if the mouseover event is triggered by the ensureHighlightVisible function call. stopPropagation if so
3635

3736
//From view --> model
3837
ngModel.$parsers.unshift(function (inputValue) {
@@ -81,26 +80,15 @@
8180
$select.selected = ngModel.$viewValue;
8281
};
8382

84-
// element.on('focusin', function(){
85-
// console.log('focusin event on dropdown-list')
86-
// });
8783

88-
// element.on('mouseover', function(){
89-
// console.log('mouseover event bubble mode');
90-
// });
91-
92-
element[0].addEventListener('mouseover', function(e){
93-
console.log('mouseover event capture mode');
94-
if (scrollFlag){
95-
e.preventDefault();
96-
e.stopPropagation();
97-
}
98-
scrollFlag = false;
99-
}, true);
84+
element.on('focus', function(){
85+
console.log('focus event on dropdown-list')
86+
});
10087

10188
// handle key press
10289
element.on('keydown', function(e) {
10390
var key = e.which;
91+
console.log('key event on dropdown-list');
10492
scope.$apply(function() {
10593
var processed = false;
10694
if (!processed && $select.items.length > 0) {
@@ -109,13 +97,14 @@
10997
if (processed) {
11098
//TODO Check si el tab selecciona aun correctamente
11199
//Crear test
112-
console.log('processed');
113100
e.preventDefault();
114101
e.stopPropagation();
115102
}
116103
if((key === 38 || key ===40) && $select.items.length > 0){
117104
ensureHighlightVisible();
118105
}
106+
107+
119108
});
120109
});
121110

@@ -134,15 +123,15 @@
134123
}
135124
});
136125

137-
// when move UP/DOWN, ensure that the dropdown scrolls to keep the current highlighted item in sight
126+
// when move the UP/DOWN, ensure that the dropdown scrolls to keep the current highlighted item in sight
138127
function ensureHighlightVisible() {
139-
scrollFlag = true;
128+
// debugger;
140129
var container = angular.element(element[0].querySelectorAll('.acq-dropdown-item'));
141130
var choices = angular.element(container[0].querySelectorAll('.acq-dropdown-item-row'));
142-
// if (choices.length < 1) {
143-
// throw uiSelectMinErr('choices', "Expected multiple .ui-select-choices-row but got '{0}'.", choices.length);
144-
// }
145-
// debugger;
131+
if (choices.length < 1) {
132+
throw uiSelectMinErr('choices', "Expected multiple .ui-select-choices-row but got '{0}'.", choices.length);
133+
}
134+
146135
var highlighted = choices[$select.activeIndex];
147136
var posY = highlighted.offsetTop + highlighted.clientHeight - container[0].scrollTop;
148137
var height = container[0].offsetHeight;
@@ -175,11 +164,12 @@
175164
$document.on('click', onDocumentClick);
176165

177166
element.on('$destroy', function(){
178-
167+
console.log('dropdow-list directive element destroy');
179168
});
180169

181170
scope.$on('$destroy', function() {
182171
$document.off('click', onDocumentClick);
172+
console.log('dropdow-list directive scope destroy');
183173
});
184174

185175
transcludeFn(scope, function(clone) {

app/scripts/directives/dropdownListCtrl.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
ctrl.open = false;
4242

4343
var _searchInput = $element.querySelectorAll('input.ui-select-search');
44-
4544
var threshold = $element.attr('search-threshold') === undefined ? ctrl.searchThreshold : $element.attr('search-threshold');
45+
console.log(threshold);
4646

4747
ctrl.isEmpty = function () {
4848
return angular.isUndefined(ctrl.selected) || ctrl.selected === null || ctrl.selected === '';
@@ -72,6 +72,7 @@
7272
};
7373

7474
function resetSearchInput() {
75+
// console.log(ctrl.items.length);
7576
if (ctrl.resetSearchInput) {
7677
ctrl.search = '';
7778
//reset activeIndex
@@ -149,7 +150,6 @@
149150
ctrl.setActiveItem = function (item) {
150151
// debugger;
151152
// console.log(ctrl.items.length);
152-
console.log('set active item called');
153153
ctrl.activeIndex = ctrl.items.indexOf(item);
154154
};
155155

@@ -204,7 +204,7 @@
204204
break;
205205
case KEY.UP:
206206
if (!ctrl.open && ctrl.multiple) ctrl.activate(false, true); //In case its the search input in 'multiple' mode
207-
else if (ctrl.activeIndex > 0) { ctrl.activeIndex--; }
207+
else if (ctrl.activeIndex > 0 || (ctrl.search.length === 0)) { ctrl.activeIndex--; }
208208
break;
209209
case KEY.TAB:
210210
if (!ctrl.multiple || ctrl.open) ctrl.select(ctrl.items[ctrl.activeIndex], true);

0 commit comments

Comments
 (0)