feat(autocomplete): optimize some const of autocomplete (#2593)

* feat(autocomplete): optimize some const of autocomplete

* feat(autocomplete): optimize some const of autocomplete
This commit is contained in:
ZenQuan 2021-07-21 22:47:51 +08:00 committed by GitHub
parent 0bf673def1
commit 6a7b9a4d8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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}`)