fix(components): [select-v2] empty value should be undefined (#10189)

This commit is contained in:
zz 2022-10-22 21:11:41 +08:00 committed by GitHub
parent d3a32cdd0b
commit 99fe8b2588
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -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', () => {

View File

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