mirror of
https://github.com/element-plus/element-plus.git
synced 2025-03-13 15:57:11 +08:00
fix: select-v2's dropdown width wrong if create in style(display: none) (#2791)
Co-authored-by: zhaozhongyu <zhaozhongyu@xunlei.com>
This commit is contained in:
parent
fe9600c181
commit
2111d8a88f
@ -72,6 +72,7 @@ const useSelect = (props: ExtractPropTypes<typeof SelectProps>, emit) => {
|
||||
|
||||
// data refs
|
||||
const selectedIndex = ref(-1)
|
||||
const popperSize = ref(-1)
|
||||
|
||||
// DOM & Component refs
|
||||
const controlRef = ref(null)
|
||||
@ -157,9 +158,9 @@ const useSelect = (props: ExtractPropTypes<typeof SelectProps>, emit) => {
|
||||
|
||||
const collapseTagSize = computed(() => selectSize.value)
|
||||
|
||||
const popperSize = computed(() => {
|
||||
return selectRef.value?.getBoundingClientRect?.()?.width || 200
|
||||
})
|
||||
const calculatePopperSize = () => {
|
||||
popperSize.value = selectRef.value?.getBoundingClientRect?.()?.width || 200
|
||||
}
|
||||
// const readonly = computed(() => !props.filterable || props.multiple || (!isIE() && !isEdge() && !expanded.value))
|
||||
|
||||
const inputWrapperStyle = computed(() => {
|
||||
@ -345,6 +346,7 @@ const useSelect = (props: ExtractPropTypes<typeof SelectProps>, emit) => {
|
||||
|
||||
const handleResize = () => {
|
||||
resetInputWidth()
|
||||
calculatePopperSize()
|
||||
popper.value?.update?.()
|
||||
if (props.multiple) resetInputHeight()
|
||||
}
|
||||
@ -616,6 +618,7 @@ const useSelect = (props: ExtractPropTypes<typeof SelectProps>, emit) => {
|
||||
states.selectedLabel = ''
|
||||
}
|
||||
}
|
||||
calculatePopperSize()
|
||||
}
|
||||
|
||||
// in order to track these individually, we need to turn them into refs instead of watching the entire
|
||||
|
Loading…
Reference in New Issue
Block a user