mirror of
https://github.com/element-plus/element-plus.git
synced 2025-01-12 10:45:10 +08:00
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:
parent
0bf673def1
commit
6a7b9a4d8b
@ -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}`)
|
||||
|
Loading…
Reference in New Issue
Block a user