From 2f69776b30558cad51d96bb0bc04032ced092a0b Mon Sep 17 00:00:00 2001 From: qiang Date: Wed, 14 Aug 2024 10:50:23 +0800 Subject: [PATCH] fix(components): [select] binding click event is invalid (#17876) * fix(components): [select] binding click event is invalid closed #17863 * chore: typo --- .../components/select-v2/__tests__/select.test.ts | 12 ++++++++++++ packages/components/select-v2/src/select.vue | 2 +- packages/components/select/__tests__/select.test.ts | 10 ++++++++++ packages/components/select/src/select.vue | 2 +- 4 files changed, 24 insertions(+), 2 deletions(-) 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" >