Skip to content

Commit

Permalink
Refactor #1362
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Sep 15, 2021
1 parent d9d871e commit 18c228e
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/components/autocomplete/AutoComplete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ export default {
this.bindOutsideClickListener();
this.bindScrollListener();
this.bindResizeListener();
if (this.autoHighlight && this.suggestions && this.suggestions.length) {
DomHandler.addClass(this.overlay.firstElementChild.firstElementChild, 'p-highlight')
}
},
onOverlayLeave() {
this.unbindOutsideClickListener();
Expand Down Expand Up @@ -325,10 +329,6 @@ export default {
},
showOverlay() {
this.overlayVisible = true;
setTimeout(()=>{
this.autoHighlightFirstItem()
},200)
},
hideOverlay() {
this.overlayVisible = false;
Expand Down Expand Up @@ -391,16 +391,10 @@ export default {
onBlur() {
this.focused = false;
},
autoHighlightFirstItem() {
if (this.autoHighlight && this.suggestions && this.suggestions.length) {
const itemToHighlight = this.overlay.firstElementChild.firstElementChild
DomHandler.addClass(itemToHighlight, 'p-highlight')
}
},
onKeyDown(event) {
if (this.overlayVisible) {
let highlightItem = DomHandler.findSingle(this.overlay, 'li.p-highlight');
switch(event.which) {
//down
case 40:
Expand Down

0 comments on commit 18c228e

Please sign in to comment.