mirror of
https://github.com/element-plus/element-plus.git
synced 2025-02-05 11:21:11 +08:00
fix(select): fix not scroll to default option (#1397)
This commit is contained in:
parent
13574d9e1a
commit
c11e572af1
@ -520,16 +520,22 @@ 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) ? option[0]?.$el : option.$el
|
||||
const target = Array.isArray(option) ? getEl(option[0]) : getEl(option)
|
||||
if (popper.value && target) {
|
||||
const menu = popper.value?.$el?.querySelector?.('.el-select-dropdown__wrap')
|
||||
const menu = popper.value?.popperRef?.querySelector?.('.el-select-dropdown__wrap')
|
||||
if (menu) {
|
||||
scrollIntoView(menu, target)
|
||||
}
|
||||
}
|
||||
// TODO: handleScroll
|
||||
// scrollbar.value?.handleScroll()
|
||||
scrollbar.value?.handleScroll()
|
||||
}
|
||||
|
||||
const onOptionCreate = (vm: ComponentPublicInstance) => {
|
||||
|
Loading…
Reference in New Issue
Block a user