mirror of
https://github.com/element-plus/element-plus.git
synced 2025-02-17 11:49:41 +08:00
fix(components): [el-select] (#5952)
This commit is contained in:
parent
bc7317203b
commit
e901c58c63
@ -1685,4 +1685,30 @@ describe('Select', () => {
|
||||
).toBe('')
|
||||
})
|
||||
})
|
||||
|
||||
it('multiple select has an initial value', async () => {
|
||||
const options = [{ value: `value:Alaska`, label: `label:Alaska` }]
|
||||
const modelValue = [{ value: `value:Alaska`, label: `label:Alaska` }]
|
||||
const wrapper = _mount(
|
||||
`
|
||||
<el-select v-model="modelValue"
|
||||
multiple
|
||||
value-key="value"
|
||||
filterable>
|
||||
<el-option
|
||||
v-for="option in options"
|
||||
:key="option.value"
|
||||
:value="option.value"
|
||||
:label="option.label"
|
||||
>
|
||||
</el-option>
|
||||
</el-select>`,
|
||||
() => ({
|
||||
modelValue,
|
||||
options,
|
||||
})
|
||||
)
|
||||
const select = wrapper.findComponent({ name: 'ElSelect' }).vm
|
||||
expect(select.selected[0].currentLabel).toBe(options[0].label)
|
||||
})
|
||||
})
|
||||
|
@ -476,7 +476,11 @@ export const useSelect = (props, states: States, ctx) => {
|
||||
}
|
||||
}
|
||||
if (option) return option
|
||||
const label = !isObjectValue && !isNull && !isUndefined ? value : ''
|
||||
const label = isObjectValue
|
||||
? value.label
|
||||
: !isNull && !isUndefined
|
||||
? value
|
||||
: ''
|
||||
const newOption = {
|
||||
value,
|
||||
currentLabel: label,
|
||||
|
Loading…
Reference in New Issue
Block a user