mirror of
https://github.com/element-plus/element-plus.git
synced 2025-02-23 11:59:34 +08:00
fix(components): [select-v2] set modalValue when filtering display error (#15981)
fix(components): [select-v2] set modalValue when filtering closed #15973
This commit is contained in:
parent
9480129c85
commit
3f4bee5a90
@ -803,6 +803,26 @@ describe('Select', () => {
|
||||
placeholder = wrapper.find(`.${PLACEHOLDER_CLASS_NAME}`)
|
||||
expect(placeholder.exists()).toBeTruthy()
|
||||
})
|
||||
|
||||
it('set modelValue when filtering in multiple select', async () => {
|
||||
const wrapper = createSelect({
|
||||
data: () => {
|
||||
return {
|
||||
multiple: true,
|
||||
filterable: true,
|
||||
value: [],
|
||||
}
|
||||
},
|
||||
})
|
||||
const vm = wrapper.vm as any
|
||||
const input = wrapper.find('input')
|
||||
await input.trigger('click')
|
||||
input.element.value = '1111'
|
||||
await input.trigger('input')
|
||||
vm.value = ['option_1']
|
||||
await nextTick()
|
||||
expect(wrapper.find('.el-select__tags-text').text()).toBe('a0')
|
||||
})
|
||||
})
|
||||
|
||||
describe('event', () => {
|
||||
|
@ -223,6 +223,15 @@ const useSelect = (props: ISelectV2Props, emit) => {
|
||||
filteredOptions.value = filterOptions(states.inputValue) as OptionType[]
|
||||
}
|
||||
|
||||
const allOptionsValueMap = computed(() => {
|
||||
const valueMap = new Map()
|
||||
|
||||
allOptions.value.forEach((option, index) => {
|
||||
valueMap.set(getValueKey(getValue(option)), { option, index })
|
||||
})
|
||||
return valueMap
|
||||
})
|
||||
|
||||
const filteredOptionsValueMap = computed(() => {
|
||||
const valueMap = new Map()
|
||||
|
||||
@ -711,8 +720,8 @@ const useSelect = (props: ISelectV2Props, emit) => {
|
||||
// match the option with the given value, if not found, create a new option
|
||||
const selectValue = getValueKey(value)
|
||||
|
||||
if (filteredOptionsValueMap.value.has(selectValue)) {
|
||||
const { option } = filteredOptionsValueMap.value.get(selectValue)
|
||||
if (allOptionsValueMap.value.has(selectValue)) {
|
||||
const { option } = allOptionsValueMap.value.get(selectValue)
|
||||
|
||||
return option
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user