mirror of
https://github.com/element-plus/element-plus.git
synced 2024-12-21 02:50:11 +08:00
fix(select): fix bug cause by scrollToOption (#1440)
This commit is contained in:
parent
fcf86b9730
commit
1bca12d6ae
@ -520,15 +520,17 @@ export const useSelect = (props, states: States, ctx) => {
|
||||
}
|
||||
}
|
||||
|
||||
const getEl = option => {
|
||||
const options = states.options.filter(item => item.value === option.value)
|
||||
if (options.length > 0) {
|
||||
return options[0].$el
|
||||
}
|
||||
}
|
||||
|
||||
const scrollToOption = option => {
|
||||
const target = Array.isArray(option) ? getEl(option[0]) : getEl(option)
|
||||
const targetOption = Array.isArray(option) ? option[0] : option
|
||||
let target = null
|
||||
|
||||
if(targetOption?.value){
|
||||
const options = states.options.filter(item => item.value === targetOption.value)
|
||||
if (options.length > 0) {
|
||||
target = options[0].$el
|
||||
}
|
||||
}
|
||||
|
||||
if (popper.value && target) {
|
||||
const menu = popper.value?.popperRef?.querySelector?.('.el-select-dropdown__wrap')
|
||||
if (menu) {
|
||||
|
Loading…
Reference in New Issue
Block a user