fix(components): [select] binding click event is invalid (#17876)

* fix(components): [select] binding click event is invalid

closed #17863

* chore: typo
This commit is contained in:
qiang 2024-08-14 10:50:23 +08:00 committed by GitHub
parent c2ad4f222c
commit 2f69776b30
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 24 additions and 2 deletions

View File

@ -1867,4 +1867,16 @@ describe('Select', () => {
// after deletion, an el-tag still exist
expect(wrapper.findAll('.el-tag').length).toBe(1)
})
it('should be trigger the click event', async () => {
const handleClick = vi.fn()
const wrapper = _mount(`<el-select :options="[]" @click="handleClick" />`, {
methods: {
handleClick,
},
})
await wrapper.find(`.${WRAPPER_CLASS_NAME}`).trigger('click')
expect(handleClick).toHaveBeenCalledOnce()
})
})

View File

@ -34,7 +34,7 @@
nsSelect.is('filterable', filterable),
nsSelect.is('disabled', selectDisabled),
]"
@click.prevent.stop="toggleMenu"
@click.prevent="toggleMenu"
>
<div
v-if="$slots.prefix"

View File

@ -2731,4 +2731,14 @@ describe('Select', () => {
expect(wrapper.findAll('.el-tag')[1].text()).toBe('1')
})
})
it('should be trigger the click event', async () => {
const handleClick = vi.fn()
const wrapper = _mount(`<el-select @click="handleClick" />`, () => ({
handleClick,
}))
await wrapper.find(`.${WRAPPER_CLASS_NAME}`).trigger('click')
expect(handleClick).toHaveBeenCalledOnce()
})
})

View File

@ -34,7 +34,7 @@
nsSelect.is('filterable', filterable),
nsSelect.is('disabled', selectDisabled),
]"
@click.prevent.stop="toggleMenu"
@click.prevent="toggleMenu"
>
<div
v-if="$slots.prefix"