From be5270dea12ceacab306fd46f7fb3d4e40681c78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=98=89=E6=B6=B5?= Date: Sun, 5 May 2019 10:14:30 +0800 Subject: [PATCH] [bugfix] Popup: click-overlay triggered twice --- packages/overlay/index.tsx | 3 --- packages/popup/test/index.spec.js | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/overlay/index.tsx b/packages/overlay/index.tsx index dae07e1a2..bd6323de5 100644 --- a/packages/overlay/index.tsx +++ b/packages/overlay/index.tsx @@ -39,9 +39,6 @@ function Overlay( event.preventDefault(); event.stopPropagation(); }} - onClick={(event: Event) => { - emit(ctx, 'click', event); - }} {...inherit(ctx, true)} /> diff --git a/packages/popup/test/index.spec.js b/packages/popup/test/index.spec.js index 7c1b9558d..ac84619c5 100644 --- a/packages/popup/test/index.spec.js +++ b/packages/popup/test/index.spec.js @@ -146,12 +146,18 @@ test('watch overlay prop', () => { expect(div.querySelector('.van-overlay')).toBeTruthy(); }); -test('close on click modal', () => { +test('close on click overlay', () => { const div = document.createElement('div'); + const onClickOverlay = jest.fn(); + wrapper = mount({ template: `
- +
`, components: { @@ -162,13 +168,18 @@ test('close on click modal', () => { value: true, getContainer: () => div }; + }, + methods: { + onClickOverlay } }); const modal = div.querySelector('.van-overlay'); triggerDrag(modal, 0, -30); modal.click(); + expect(wrapper.vm.value).toBeFalsy(); + expect(onClickOverlay).toHaveBeenCalledTimes(1); }); test('oepn & close event', () => {