diff --git a/packages/select-v2/src/useSelect.ts b/packages/select-v2/src/useSelect.ts index 032a5fa09f..3e34e2024e 100644 --- a/packages/select-v2/src/useSelect.ts +++ b/packages/select-v2/src/useSelect.ts @@ -72,6 +72,7 @@ const useSelect = (props: ExtractPropTypes, 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, 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, emit) => { const handleResize = () => { resetInputWidth() + calculatePopperSize() popper.value?.update?.() if (props.multiple) resetInputHeight() } @@ -616,6 +618,7 @@ const useSelect = (props: ExtractPropTypes, emit) => { states.selectedLabel = '' } } + calculatePopperSize() } // in order to track these individually, we need to turn them into refs instead of watching the entire