Skip to content

Commit

Permalink
feat(autocomplete): optimize some const of autocomplete (element-plus…
Browse files Browse the repository at this point in the history
…#2593)

* feat(autocomplete): optimize some const of autocomplete

* feat(autocomplete): optimize some const of autocomplete
  • Loading branch information
Zenquan authored Jul 21, 2021
1 parent 0bf673d commit 6a7b9a4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/autocomplete/src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,13 @@ export default defineComponent({
const suggestionList = suggestion.querySelectorAll('.el-autocomplete-suggestion__list li')
const highlightItem = suggestionList[index]
const scrollTop = suggestion.scrollTop
const offsetTop = highlightItem.offsetTop
const { offsetTop, scrollHeight } = highlightItem
if (offsetTop + highlightItem.scrollHeight > (scrollTop + suggestion.clientHeight)) {
suggestion.scrollTop += highlightItem.scrollHeight
if (offsetTop + scrollHeight > (scrollTop + suggestion.clientHeight)) {
suggestion.scrollTop += scrollHeight
}
if (offsetTop < scrollTop) {
suggestion.scrollTop -= highlightItem.scrollHeight
suggestion.scrollTop -= scrollHeight
}
highlightedIndex.value = index
inputRef.value.inputOrTextarea.setAttribute('aria-activedescendant', `${id.value}-item-${highlightedIndex.value}`)
Expand Down

0 comments on commit 6a7b9a4

Please sign in to comment.