2
0
mirror of https://github.com/frappe/books.git synced 2024-12-23 11:29:03 +00:00

Fix keyboard navigation in Autocomplete

This commit is contained in:
Faris Ansari 2018-09-27 17:15:12 +05:30
parent 66ee79db22
commit 81f48eab83

View File

@ -22,11 +22,11 @@ export default {
keydown: e => {
if (e.keyCode === 38) {
// up
this.highlightedItem -= 1;
this.highlightAboveItem();
}
if (e.keyCode === 40) {
// down
this.highlightedItem += 1;
this.highlightBelowItem();
}
if (e.keyCode === 13) {
if (this.highlightedItem > -1) {
@ -45,6 +45,18 @@ export default {
}
}
},
highlightBelowItem() {
this.highlightedItem += 1;
if (this.highlightedItem > this.popupItems.length - 1) {
this.highlightedItem = this.popupItems.length - 1;
}
},
highlightAboveItem() {
this.highlightedItem -= 1;
if (this.highlightedItem < 0) {
this.highlightedItem = 0;
}
},
getChildrenElement(h) {
return [
this.onlyInput ? null : this.getLabelElement(h),