diff --git a/packages/components/select/__tests__/select.test.ts b/packages/components/select/__tests__/select.test.ts index 57fcccc3d9..ed3cff67c8 100644 --- a/packages/components/select/__tests__/select.test.ts +++ b/packages/components/select/__tests__/select.test.ts @@ -1058,12 +1058,15 @@ describe('Select', () => { selectWrapper.vm.handleResize() options[0].click() await nextTick() + const tagWrappers = wrapper.findAll('.el-select__tags-text') + const tagWrapperDom = tagWrappers[0].element + expect(Number.parseInt(tagWrapperDom.style.maxWidth) === 200 - 75).toBe( + true + ) options[1].click() await nextTick() options[2].click() await nextTick() - const tagWrappers = wrapper.findAll('.el-select__tags-text') - const tagWrapperDom = tagWrappers[0].element expect(Number.parseInt(tagWrapperDom.style.maxWidth) === 200 - 123).toBe( true ) diff --git a/packages/components/select/src/select.vue b/packages/components/select/src/select.vue index 19434baba4..e13fd4ef56 100644 --- a/packages/components/select/src/select.vue +++ b/packages/components/select/src/select.vue @@ -693,7 +693,8 @@ export default defineComponent({ const tagTextStyle = computed(() => { const maxWidth = - unref(inputWidth) > 123 + unref(inputWidth) > 123 && + unref(selected).length > props.maxCollapseTags ? unref(inputWidth) - 123 : unref(inputWidth) - 75 return { maxWidth: `${maxWidth}px` }