fix(select): emit blur event (#1504) (#1506)

This commit is contained in:
Ernest 2021-02-26 20:58:05 +08:00 committed by GitHub
parent abe02101fa
commit 3bbcec8a10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions

View File

@ -519,6 +519,29 @@ describe('Select', () => {
expect(handleBlur).toHaveBeenCalled()
})
test('event:focus & blur for multile & filterable select', async () => {
const handleFocus = jest.fn()
const handleBlur = jest.fn()
const wrapper = _mount(`
<el-select
@focus="handleFocus"
@blur="handleBlur"
multiple
filterable
/>`, () => ({
handleFocus,
handleBlur,
}))
const select = wrapper.findComponent(({ name: 'ElSelect' }))
const input = select.find('input')
expect(input.exists()).toBe(true)
await input.trigger('focus')
expect(handleFocus).toHaveBeenCalled()
await input.trigger('blur')
expect(handleBlur).toHaveBeenCalled()
})
test('should not open popper when automatic-dropdown not set', async () => {
const wrapper = getSelectVm()
const select = wrapper.findComponent({ name: 'ElSelect' })

View File

@ -79,7 +79,7 @@
:autocomplete="autocomplete"
:style="{ 'flex-grow': '1', width: inputLength / (inputWidth - 32) + '%', 'max-width': inputWidth - 42 + 'px' }"
@focus="handleFocus"
@blur="softFocus = false"
@blur="handleBlur"
@keyup="managePlaceholder"
@keydown="resetInputState"
@keydown.down.prevent="navigateOptions('next')"