mirror of
https://github.com/element-plus/element-plus.git
synced 2025-04-06 16:30:35 +08:00
fix(components): [el-select-v2] use :model-value
without changes (#20149)
fix(components): [el-select-v2] model-value bug
This commit is contained in:
parent
e9d82e59e9
commit
a3e774e12c
@ -1488,6 +1488,35 @@ describe('Select', () => {
|
||||
expect(wrapper.findAll('.el-tag').length).toBe(2)
|
||||
})
|
||||
|
||||
it('tag list should be empty when model-value is empty', async () => {
|
||||
const wrapper = _mount(
|
||||
`<el-select
|
||||
model-value=""
|
||||
:options="[
|
||||
{
|
||||
value: 1,
|
||||
label: 1,
|
||||
},
|
||||
]"
|
||||
multiple
|
||||
/>`
|
||||
)
|
||||
await wrapper.find(`.${WRAPPER_CLASS_NAME}`).trigger('click')
|
||||
|
||||
const option = document.querySelector(`.${OPTION_ITEM_CLASS_NAME}`)
|
||||
option.click()
|
||||
await nextTick()
|
||||
|
||||
option.click()
|
||||
await nextTick()
|
||||
|
||||
option.click()
|
||||
await nextTick()
|
||||
|
||||
await nextTick()
|
||||
expect(wrapper.findAll('.el-tag').length).toBe(0)
|
||||
})
|
||||
|
||||
it('should reset placeholder after clear when both multiple and filterable are true', async () => {
|
||||
const wrapper = createSelect({
|
||||
data() {
|
||||
|
@ -548,6 +548,14 @@ const useSelect = (props: ISelectV2Props, emit: SelectEmitFn) => {
|
||||
selectedOptions = [...selectedOptions, getValue(option)]
|
||||
states.cachedOptions.push(option)
|
||||
selectNewOption(option)
|
||||
|
||||
nextTick(() => {
|
||||
const isModelChanged = isEqual(selectedOptions, props.modelValue)
|
||||
|
||||
if (!isModelChanged) {
|
||||
states.cachedOptions.pop()
|
||||
}
|
||||
})
|
||||
}
|
||||
update(selectedOptions)
|
||||
if (option.created) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user