fix(components): [select] style error in multiple collapseTags (#14602)

This commit is contained in:
Fuphoenixes 2023-11-11 21:27:35 +08:00 committed by GitHub
parent dfad5539f5
commit 4580aea8e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

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

View File

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