diff --git a/src/popover/README.md b/src/popover/README.md index 475bf6226..45fe3ae75 100644 --- a/src/popover/README.md +++ b/src/popover/README.md @@ -164,6 +164,7 @@ export default { | actions | Actions | _Action[]_ | `[]` | | placement | Placement | _string_ | `bottom` | | theme | Theme,can be set to `dark` | _string_ | `light` | +| offset | Distance to reference | _[number, number]_ | `[0, 8]` | | overlay | Whether to show overlay | _boolean_ | `false` | | close-on-click-action | Whether to close when clicking action | _boolean_ | `true` | | close-on-click-outside | Whether to close when clicking outside | _boolean_ | `true` | diff --git a/src/popover/README.zh-CN.md b/src/popover/README.zh-CN.md index 034bc2f13..dbcc02404 100644 --- a/src/popover/README.zh-CN.md +++ b/src/popover/README.zh-CN.md @@ -206,6 +206,7 @@ export default { | actions | 选项列表 | _Action[]_ | `[]` | | placement | 弹出位置 | _string_ | `bottom` | | theme | 主题风格,可选值为 `dark` | _string_ | `light` | +| offset | 出现位置的偏移量 | _[number, number]_ | `[0, 8]` | | overlay | 是否显示遮罩层 | _boolean_ | `false` | | close-on-click-action | 是否在点击选项后关闭 | _boolean_ | `true` | | close-on-click-outside | 是否在点击外部元素后关闭菜单 | _boolean_ | `true` | diff --git a/src/popover/index.js b/src/popover/index.js index 04f846648..9b5339947 100644 --- a/src/popover/index.js +++ b/src/popover/index.js @@ -29,8 +29,6 @@ export default createComponent({ props: { show: Boolean, overlay: Boolean, - textColor: String, - backgroundColor: String, offset: { type: Array, default: () => [0, 8], diff --git a/src/popup/README.md b/src/popup/README.md index e91c82c7f..9c2954c09 100644 --- a/src/popup/README.md +++ b/src/popup/README.md @@ -133,11 +133,12 @@ export default { ### Events -| Event | Description | Arguments | -| ------------- | ------------------------------- | -------------- | -| click | Emitted when Popup is clicked | _event: Event_ | -| open | Emitted when opening Popup | - | -| close | Emitted when closing Popup | - | -| opened | Emitted when Popup is opened | - | -| closed | Emitted when Popup is closed | - | -| click-overlay | Emitted when overlay is clicked | - | +| Event | Description | Arguments | +| --- | --- | --- | +| click | Emitted when Popup is clicked | _event: Event_ | +| click-overlay | Emitted when overlay is clicked | - | +| click-close-icon `v2.11.0` | Emitted when close icon is clicked | _event: Event_ | +| open | Emitted when opening Popup | - | +| close | Emitted when closing Popup | - | +| opened | Emitted when Popup is opened | - | +| closed | Emitted when Popup is closed | - | diff --git a/src/popup/README.zh-CN.md b/src/popup/README.zh-CN.md index 3d85e35b2..b849eedf9 100644 --- a/src/popup/README.zh-CN.md +++ b/src/popup/README.zh-CN.md @@ -143,11 +143,12 @@ export default { ### Events -| 事件名 | 说明 | 回调参数 | -| ------------- | -------------------------- | -------------- | -| click | 点击弹出层时触发 | _event: Event_ | -| open | 打开弹出层时触发 | - | -| close | 关闭弹出层时触发 | - | -| opened | 打开弹出层且动画结束后触发 | - | -| closed | 关闭弹出层且动画结束后触发 | - | -| click-overlay | 点击遮罩层时触发 | - | +| 事件名 | 说明 | 回调参数 | +| -------------------------- | -------------------------- | -------------- | +| click | 点击弹出层时触发 | _event: Event_ | +| click-overlay | 点击遮罩层时触发 | - | +| click-close-icon `v2.11.0` | 点击关闭图标时触发 | _event: Event_ | +| open | 打开弹出层时触发 | - | +| close | 关闭弹出层时触发 | - | +| opened | 打开弹出层且动画结束后触发 | - | +| closed | 关闭弹出层且动画结束后触发 | - | diff --git a/src/popup/index.js b/src/popup/index.js index 44a548be5..b00ca1ce6 100644 --- a/src/popup/index.js +++ b/src/popup/index.js @@ -102,6 +102,7 @@ export default createComponent({ 'closed', 'update:show', 'click-overlay', + 'click-close-icon', ], setup(props, { emit, attrs, slots }) { @@ -173,6 +174,11 @@ export default createComponent({ } }; + const onClickCloseIcon = (event) => { + emit('click-close-icon', event); + close(); + }; + const renderCloseIcon = () => { if (props.closeable) { return ( @@ -181,7 +187,7 @@ export default createComponent({ tabindex="0" name={props.closeIcon} class={bem('close-icon', props.closeIconPosition)} - onClick={close} + onClick={onClickCloseIcon} /> ); } diff --git a/src/popup/test/index.legacy.js b/src/popup/test/index.legacy.js index 6534fa14a..f7e185852 100644 --- a/src/popup/test/index.legacy.js +++ b/src/popup/test/index.legacy.js @@ -252,6 +252,18 @@ test('closeable prop', () => { expect(wrapper.emitted('input')[0][0]).toEqual(false); }); +test('should emit click-close-icon event when close icon is clicked', () => { + const wrapper = mount(Popup, { + propsData: { + value: true, + closeable: true, + }, + }); + + wrapper.find('.van-popup__close-icon').trigger('click'); + expect(wrapper.emitted('click-close-icon').length).toEqual(1); +}); + test('close-icon prop', () => { const wrapper = mount(Popup, { props: {