diff --git a/packages/components/select-v2/__tests__/select.test.ts b/packages/components/select-v2/__tests__/select.test.ts index ebbaf05ef3..4196a21eb5 100644 --- a/packages/components/select-v2/__tests__/select.test.ts +++ b/packages/components/select-v2/__tests__/select.test.ts @@ -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(``, { + methods: { + handleClick, + }, + }) + + await wrapper.find(`.${WRAPPER_CLASS_NAME}`).trigger('click') + expect(handleClick).toHaveBeenCalledOnce() + }) }) diff --git a/packages/components/select-v2/src/select.vue b/packages/components/select-v2/src/select.vue index 5472f59b65..46853c9c84 100644 --- a/packages/components/select-v2/src/select.vue +++ b/packages/components/select-v2/src/select.vue @@ -34,7 +34,7 @@ nsSelect.is('filterable', filterable), nsSelect.is('disabled', selectDisabled), ]" - @click.prevent.stop="toggleMenu" + @click.prevent="toggleMenu" >
{ expect(wrapper.findAll('.el-tag')[1].text()).toBe('1') }) }) + + it('should be trigger the click event', async () => { + const handleClick = vi.fn() + const wrapper = _mount(``, () => ({ + handleClick, + })) + + await wrapper.find(`.${WRAPPER_CLASS_NAME}`).trigger('click') + expect(handleClick).toHaveBeenCalledOnce() + }) }) diff --git a/packages/components/select/src/select.vue b/packages/components/select/src/select.vue index 50c4c3f58c..288110aefc 100644 --- a/packages/components/select/src/select.vue +++ b/packages/components/select/src/select.vue @@ -34,7 +34,7 @@ nsSelect.is('filterable', filterable), nsSelect.is('disabled', selectDisabled), ]" - @click.prevent.stop="toggleMenu" + @click.prevent="toggleMenu" >