2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2024-11-29 00:06:36 +00:00

Fix an issue with arrow selection of elements with top orientation

If the orientation of the dropdown is `top`, the user could not hit the up arrow
to select an element in the dropdown.
This commit is contained in:
Dan Schultz 2014-08-11 10:30:59 -07:00
parent a9e79277fb
commit b06f53edc6

View File

@ -132,6 +132,8 @@
killerFn: null,
displayedOrientation: null,
initialize: function () {
var that = this,
suggestionSelector = '.' + that.classes.suggestion,
@ -289,6 +291,8 @@
else
styles.top += height;
that.displayedOrientation = orientation;
// If container is not positioned to body,
// correct its position using offset parent offset
if(containerParent !== document.body) {
@ -788,6 +792,7 @@
moveUp: function () {
var that = this;
if (that.displayedOrientation === 'bottom') {
if (that.selectedIndex === -1) {
return;
}
@ -799,6 +804,16 @@
that.findBestHint();
return;
}
} else {
if (that.selectedIndex === -1) {
that.adjustScroll(that.suggestions.length - 1);
return;
}
if (that.selectedIndex === 0) {
return;
}
}
that.adjustScroll(that.selectedIndex - 1);
},
@ -806,9 +821,19 @@
moveDown: function () {
var that = this;
if (that.displayedOrientation === 'bottom') {
if (that.selectedIndex === (that.suggestions.length - 1)) {
return;
}
} else {
if (that.selectedIndex == -1) {
return;
}
if (that.selectedIndex > (that.suggestions.length - 1)) {
return;
}
}
that.adjustScroll(that.selectedIndex + 1);
},