Skip to content

Commit e7d935c

Browse files
committed
feat: popconfirm add disabled support
1 parent 2200cf0 commit e7d935c

File tree

6 files changed

+49
-16
lines changed

6 files changed

+49
-16
lines changed

build/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
22
dev: {
3-
componentName: 'pagination', // dev components
3+
componentName: 'popconfirm', // dev components
44
},
55
};

components/popconfirm/__tests__/index.test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,27 @@ describe('Popconfirm', () => {
7272
expect(popup.innerHTML).toMatchSnapshot();
7373
}, 1000);
7474
});
75+
76+
it('should not open in disabled', async () => {
77+
const popconfirm = mount(
78+
{
79+
render() {
80+
return (
81+
<Popconfirm ref="popconfirm" title="code" disabled>
82+
<span>click me</span>
83+
</Popconfirm>
84+
);
85+
},
86+
},
87+
{ sync: false },
88+
);
89+
90+
await asyncExpect(() => {
91+
popconfirm.find('span').trigger('click');
92+
}, 1000);
93+
await asyncExpect(() => {
94+
const popup = popconfirm.vm.$refs.popconfirm.getPopupDomNode();
95+
expect(popup).toBeFalsy();
96+
}, 1000);
97+
});
7598
});

components/popconfirm/index.en-US.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
## API
22

3-
| Param | Description | Type | Default value |
4-
| --- | --- | --- | --- |
5-
| cancelText | text of the Cancel button | string\|slot | `Cancel` |
6-
| okText | text of the Confirm button | string\|slot | `Confirm` |
7-
| okType | Button `type` of the Confirm button | string | `primary` |
8-
| title | title of the confirmation box | string\|slot | - |
9-
| icon | customize icon of confirmation | vNode\|slot | &lt;Icon type="exclamation-circle" /&gt; |
3+
| Param | Description | Type | Default value | Version |
4+
| --- | --- | --- | --- | --- |
5+
| cancelText | text of the Cancel button | string\|slot | `Cancel` | |
6+
| okText | text of the Confirm button | string\|slot | `Confirm` | |
7+
| okType | Button `type` of the Confirm button | string | `primary` | |
8+
| title | title of the confirmation box | string\|slot | - | |
9+
| icon | customize icon of confirmation | vNode\|slot | &lt;Icon type="exclamation-circle" /&gt; | |
10+
| disabled | is show popconfirm when click its childrenNode | boolean | false | 1.5.0 |
1011

1112
### events
1213

components/popconfirm/index.jsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const Popconfirm = {
2424
title: PropTypes.any,
2525
trigger: tooltipProps.trigger.def('click'),
2626
okType: btnProps.type.def('primary'),
27+
disabled: PropTypes.bool.def(false),
2728
okText: PropTypes.any,
2829
cancelText: PropTypes.any,
2930
icon: PropTypes.any,
@@ -48,7 +49,8 @@ const Popconfirm = {
4849
const state = { sVisible: false };
4950
if ('visible' in props) {
5051
state.sVisible = props.visible;
51-
} else if ('defaultVisible' in props) {
52+
}
53+
if ('defaultVisible' in props) {
5254
state.sVisible = props.defaultVisible;
5355
}
5456
return state;
@@ -65,6 +67,10 @@ const Popconfirm = {
6567
},
6668

6769
onVisibleChange(sVisible) {
70+
const { disabled } = this.$props;
71+
if (disabled) {
72+
return;
73+
}
6874
this.setVisible(sVisible);
6975
},
7076

components/popconfirm/index.zh-CN.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
## API
22

3-
| 参数 | 说明 | 类型 | 默认值 |
4-
| ---------- | ------------------------ | ------------ | ---------------------------------------- |
5-
| cancelText | 取消按钮文字 | string\|slot | 取消 |
6-
| okText | 确认按钮文字 | string\|slot | 确定 |
7-
| okType | 确认按钮类型 | string | primary |
8-
| title | 确认框的描述 | string\|slot ||
9-
| icon | 自定义弹出气泡 Icon 图标 | vNode | &lt;Icon type="exclamation-circle" /&gt; |
3+
| 参数 | 说明 | 类型 | 默认值 | 版本 |
4+
| --- | --- | --- | --- | --- |
5+
| cancelText | 取消按钮文字 | string\|slot | 取消 | |
6+
| okText | 确认按钮文字 | string\|slot | 确定 | |
7+
| okType | 确认按钮类型 | string | primary | |
8+
| title | 确认框的描述 | string\|slot || |
9+
| icon | 自定义弹出气泡 Icon 图标 | vNode | &lt;Icon type="exclamation-circle" /&gt; | |
10+
| disabled | 点击 Popconfirm 子元素是否弹出气泡确认框 | boolean | false | 1.5.0 |
1011

1112
### 事件
1213

types/popconfirm.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,6 @@ export declare class Popconfirm extends TooltipCommon {
3838
* @type any (VNode | slot)
3939
*/
4040
icon: any;
41+
42+
disabled: boolean;
4143
}

0 commit comments

Comments
 (0)