From 18c228eda64f74daea87a2ffaf86aa8066e5039a Mon Sep 17 00:00:00 2001 From: mertsincan Date: Wed, 15 Sep 2021 09:39:40 +0300 Subject: [PATCH] Refactor #1362 --- src/components/autocomplete/AutoComplete.vue | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/components/autocomplete/AutoComplete.vue b/src/components/autocomplete/AutoComplete.vue index 71b44c844..4725afe53 100755 --- a/src/components/autocomplete/AutoComplete.vue +++ b/src/components/autocomplete/AutoComplete.vue @@ -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(); @@ -325,10 +329,6 @@ export default { }, showOverlay() { this.overlayVisible = true; - - setTimeout(()=>{ - this.autoHighlightFirstItem() - },200) }, hideOverlay() { this.overlayVisible = false; @@ -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: