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:
zhaozhongyu 2021-08-03 08:51:08 +08:00 committed by GitHub
parent fe9600c181
commit 2111d8a88f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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