diff --git a/packages/select/__tests__/select.spec.ts b/packages/select/__tests__/select.spec.ts index bb32ce1128..b4dc54ec01 100644 --- a/packages/select/__tests__/select.spec.ts +++ b/packages/select/__tests__/select.spec.ts @@ -17,7 +17,7 @@ interface SelectProps { popperClass?: string } -const _mount = (template: string, data: any = () => ({}), otherObj?): any => mount({ +const _mount = (template: string, data: any = () => ({}), otherObj?) => mount({ components: { 'el-select': Select, 'el-option': Option, @@ -432,7 +432,6 @@ describe('Select', () => { await nextTick() const tagWrappers = wrapper.findAll('.el-select__tags-text') const tagWrapperDom = tagWrappers[0].element - console.log(tagWrapperDom.style.maxWidth) expect(parseInt(tagWrapperDom.style.maxWidth) === inputRect.width - 123).toBe(true) mockInputWidth.mockRestore() }) @@ -610,4 +609,40 @@ describe('Select', () => { await vm.$nextTick() expect(wrapper.find('.el-input__inner').element.value).toBe('黄金糕') }) + + test('emptyText error show', async () => { + const wrapper = _mount(` + + + + `, + () => ({ + options: [{ + value: 'Option1', + label: 'Option1', + }, { + value: 'Option2', + label: 'Option2', + }, { + value: 'Option3', + label: 'Option3', + }, { + value: 'Option4', + label: 'Option4', + }, { + value: 'Option5', + label: 'Option5', + }], + value: 'test', + })) + const select = wrapper.findComponent({ name: 'ElSelect' }) + select.trigger('click') + await nextTick() + expect(!!document.querySelector('.el-select__popper').style.display).toBeFalsy() + expect(wrapper.findAll('.el-select-dropdown__empty').length).toBe(0) + }) }) diff --git a/packages/select/src/useSelect.ts b/packages/select/src/useSelect.ts index c2c5746e53..a502196eb5 100644 --- a/packages/select/src/useSelect.ts +++ b/packages/select/src/useSelect.ts @@ -192,20 +192,20 @@ export const useSelect = (props, states: States, ctx) => { if (props.filterable) { states.query = props.remote ? '' : states.selectedLabel - handleQueryChange(states.query) if (props.multiple) { input.value.focus() } else { - if (!props.remote) { - states.selectEmitter.emit('elOptionQueryChange', '') - states.selectEmitter.emit('elOptionGroupQueryChange') - } - if (states.selectedLabel) { states.currentPlaceholder = states.selectedLabel states.selectedLabel = '' } } + if (!props.multiple && !props.remote) { + states.selectEmitter.emit('elOptionQueryChange', '') + states.selectEmitter.emit('elOptionGroupQueryChange') + } else { + handleQueryChange(states.query) + } } } ctx.emit('visible-change', val)