diff --git a/build/config.js b/build/config.js index e041cab95..b0712187d 100644 --- a/build/config.js +++ b/build/config.js @@ -1,5 +1,5 @@ module.exports = { dev: { - componentName: 'pagination', // dev components + componentName: 'popconfirm', // dev components }, }; diff --git a/components/popconfirm/__tests__/index.test.js b/components/popconfirm/__tests__/index.test.js index 0a8477f50..8b21d6d86 100644 --- a/components/popconfirm/__tests__/index.test.js +++ b/components/popconfirm/__tests__/index.test.js @@ -72,4 +72,27 @@ describe('Popconfirm', () => { expect(popup.innerHTML).toMatchSnapshot(); }, 1000); }); + + it('should not open in disabled', async () => { + const popconfirm = mount( + { + render() { + return ( + + click me + + ); + }, + }, + { sync: false }, + ); + + await asyncExpect(() => { + popconfirm.find('span').trigger('click'); + }, 1000); + await asyncExpect(() => { + const popup = popconfirm.vm.$refs.popconfirm.getPopupDomNode(); + expect(popup).toBeFalsy(); + }, 1000); + }); }); diff --git a/components/popconfirm/index.en-US.md b/components/popconfirm/index.en-US.md index 98dc1efb8..5bd6b32db 100644 --- a/components/popconfirm/index.en-US.md +++ b/components/popconfirm/index.en-US.md @@ -1,12 +1,13 @@ ## API -| Param | Description | Type | Default value | -| --- | --- | --- | --- | -| cancelText | text of the Cancel button | string\|slot | `Cancel` | -| okText | text of the Confirm button | string\|slot | `Confirm` | -| okType | Button `type` of the Confirm button | string | `primary` | -| title | title of the confirmation box | string\|slot | - | -| icon | customize icon of confirmation | vNode\|slot | <Icon type="exclamation-circle" /> | +| Param | Description | Type | Default value | Version | +| --- | --- | --- | --- | --- | +| cancelText | text of the Cancel button | string\|slot | `Cancel` | | +| okText | text of the Confirm button | string\|slot | `Confirm` | | +| okType | Button `type` of the Confirm button | string | `primary` | | +| title | title of the confirmation box | string\|slot | - | | +| icon | customize icon of confirmation | vNode\|slot | <Icon type="exclamation-circle" /> | | +| disabled | is show popconfirm when click its childrenNode | boolean | false | 1.5.0 | ### events diff --git a/components/popconfirm/index.jsx b/components/popconfirm/index.jsx index df7e676d5..b52446909 100644 --- a/components/popconfirm/index.jsx +++ b/components/popconfirm/index.jsx @@ -24,6 +24,7 @@ const Popconfirm = { title: PropTypes.any, trigger: tooltipProps.trigger.def('click'), okType: btnProps.type.def('primary'), + disabled: PropTypes.bool.def(false), okText: PropTypes.any, cancelText: PropTypes.any, icon: PropTypes.any, @@ -48,7 +49,8 @@ const Popconfirm = { const state = { sVisible: false }; if ('visible' in props) { state.sVisible = props.visible; - } else if ('defaultVisible' in props) { + } + if ('defaultVisible' in props) { state.sVisible = props.defaultVisible; } return state; @@ -65,6 +67,10 @@ const Popconfirm = { }, onVisibleChange(sVisible) { + const { disabled } = this.$props; + if (disabled) { + return; + } this.setVisible(sVisible); }, diff --git a/components/popconfirm/index.zh-CN.md b/components/popconfirm/index.zh-CN.md index 8a5119907..557fc5383 100644 --- a/components/popconfirm/index.zh-CN.md +++ b/components/popconfirm/index.zh-CN.md @@ -1,12 +1,13 @@ ## API -| 参数 | 说明 | 类型 | 默认值 | -| ---------- | ------------------------ | ------------ | ---------------------------------------- | -| cancelText | 取消按钮文字 | string\|slot | 取消 | -| okText | 确认按钮文字 | string\|slot | 确定 | -| okType | 确认按钮类型 | string | primary | -| title | 确认框的描述 | string\|slot | 无 | -| icon | 自定义弹出气泡 Icon 图标 | vNode | <Icon type="exclamation-circle" /> | +| 参数 | 说明 | 类型 | 默认值 | 版本 | +| --- | --- | --- | --- | --- | +| cancelText | 取消按钮文字 | string\|slot | 取消 | | +| okText | 确认按钮文字 | string\|slot | 确定 | | +| okType | 确认按钮类型 | string | primary | | +| title | 确认框的描述 | string\|slot | 无 | | +| icon | 自定义弹出气泡 Icon 图标 | vNode | <Icon type="exclamation-circle" /> | | +| disabled | 点击 Popconfirm 子元素是否弹出气泡确认框 | boolean | false | 1.5.0 | ### 事件 diff --git a/types/popconfirm.d.ts b/types/popconfirm.d.ts index 767cf5a50..44c8b796e 100644 --- a/types/popconfirm.d.ts +++ b/types/popconfirm.d.ts @@ -38,4 +38,6 @@ export declare class Popconfirm extends TooltipCommon { * @type any (VNode | slot) */ icon: any; + + disabled: boolean; }