mirror of
https://github.com/element-plus/element-plus.git
synced 2025-02-17 11:49:41 +08:00
fix(components): [select-v2] empty value should be undefined (#10189)
This commit is contained in:
parent
d3a32cdd0b
commit
99fe8b2588
@ -473,9 +473,9 @@ describe('Select', () => {
|
||||
vm.value = vm.options[1].value
|
||||
await nextTick()
|
||||
await clickClearButton(wrapper)
|
||||
expect(vm.value).toBe('')
|
||||
expect(vm.value).toBeUndefined()
|
||||
const placeholder = wrapper.find(`.${PLACEHOLDER_CLASS_NAME}`)
|
||||
expect(placeholder.text()).toBe('')
|
||||
expect(placeholder.text()).toBe(DEFAULT_PLACEHOLDER)
|
||||
})
|
||||
|
||||
describe('multiple', () => {
|
||||
|
@ -57,7 +57,7 @@ const useSelect = (props: ExtractPropTypes<typeof SelectProps>, emit) => {
|
||||
selectWidth: 200,
|
||||
initialInputHeight: 0,
|
||||
previousQuery: null,
|
||||
previousValue: '',
|
||||
previousValue: undefined,
|
||||
query: '',
|
||||
selectedLabel: '',
|
||||
softFocus: false,
|
||||
@ -324,7 +324,7 @@ const useSelect = (props: ExtractPropTypes<typeof SelectProps>, emit) => {
|
||||
const update = (val: any) => {
|
||||
emit(UPDATE_MODEL_EVENT, val)
|
||||
emitChange(val)
|
||||
states.previousValue = val.toString()
|
||||
states.previousValue = val?.toString()
|
||||
}
|
||||
|
||||
const getValueIndex = (arr = [], value: unknown) => {
|
||||
@ -512,7 +512,7 @@ const useSelect = (props: ExtractPropTypes<typeof SelectProps>, emit) => {
|
||||
if (isArray(props.modelValue)) {
|
||||
emptyValue = []
|
||||
} else {
|
||||
emptyValue = ''
|
||||
emptyValue = undefined
|
||||
}
|
||||
|
||||
states.softFocus = true
|
||||
@ -666,7 +666,7 @@ const useSelect = (props: ExtractPropTypes<typeof SelectProps>, emit) => {
|
||||
})
|
||||
} else {
|
||||
states.cachedOptions = []
|
||||
states.previousValue = ''
|
||||
states.previousValue = undefined
|
||||
}
|
||||
} else {
|
||||
if (hasModelValue.value) {
|
||||
@ -683,7 +683,7 @@ const useSelect = (props: ExtractPropTypes<typeof SelectProps>, emit) => {
|
||||
}
|
||||
} else {
|
||||
states.selectedLabel = ''
|
||||
states.previousValue = ''
|
||||
states.previousValue = undefined
|
||||
}
|
||||
}
|
||||
clearAllNewOption()
|
||||
|
Loading…
Reference in New Issue
Block a user