mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 14:13:37 +08:00
feat(popconfirm): add disabled in popconfirm
This commit is contained in:
parent
e55a254589
commit
10d4a9f955
@ -134,4 +134,15 @@ describe('Popconfirm', () => {
|
||||
);
|
||||
expect(popconfirm.instance().getPopupDomNode()).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should not open in disabled', () => {
|
||||
const popconfirm = mount(
|
||||
<Popconfirm title="code" disabled>
|
||||
<button>click me</button>
|
||||
</Popconfirm>,
|
||||
);
|
||||
const triggerNode = popconfirm.find('button').at(0);
|
||||
triggerNode.simulate('click');
|
||||
expect(popconfirm.instance().getPopupDomNode()).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
@ -23,6 +23,7 @@ The difference with the `confirm` modal dialog is that it's more lightweight tha
|
||||
| onCancel | callback of cancel | function(e) | - |
|
||||
| onConfirm | callback of confirmation | function(e) | - |
|
||||
| icon | customize icon of confirmation | ReactNode | <Icon type="exclamation-circle" /> |
|
||||
| disabled | is show popconfirm when click its childrenNode | boolean | false |
|
||||
|
||||
Consult [Tooltip's documentation](https://ant.design/components/tooltip/#API) to find more APIs.
|
||||
|
||||
|
@ -10,6 +10,7 @@ import { ConfigConsumer, ConfigConsumerProps } from '../config-provider';
|
||||
|
||||
export interface PopconfirmProps extends AbstractTooltipProps {
|
||||
title: React.ReactNode;
|
||||
disabled?: boolean;
|
||||
onConfirm?: (e?: React.MouseEvent<any>) => void;
|
||||
onCancel?: (e?: React.MouseEvent<any>) => void;
|
||||
okText?: React.ReactNode;
|
||||
@ -37,6 +38,7 @@ class Popconfirm extends React.Component<PopconfirmProps, PopconfirmState> {
|
||||
trigger: 'click' as PopconfirmProps['trigger'],
|
||||
okType: 'primary' as PopconfirmProps['okType'],
|
||||
icon: <Icon type="exclamation-circle" theme="filled" />,
|
||||
disabled: false,
|
||||
};
|
||||
|
||||
static getDerivedStateFromProps(nextProps: PopconfirmProps) {
|
||||
@ -81,6 +83,10 @@ class Popconfirm extends React.Component<PopconfirmProps, PopconfirmState> {
|
||||
};
|
||||
|
||||
onVisibleChange = (visible: boolean) => {
|
||||
const { disabled } = this.props;
|
||||
if (disabled) {
|
||||
return;
|
||||
}
|
||||
this.setVisible(visible);
|
||||
};
|
||||
|
||||
|
@ -24,6 +24,7 @@ title: Popconfirm
|
||||
| onCancel | 点击取消的回调 | function(e) | 无 |
|
||||
| onConfirm | 点击确认的回调 | function(e) | 无 |
|
||||
| icon | 自定义弹出气泡 Icon 图标 | ReactNode | <Icon type="exclamation-circle" /> |
|
||||
| disabled | 点击 Popconfirm 子元素是否弹出气泡确认框 | boolean | false |
|
||||
|
||||
更多属性请参考 [Tooltip](/components/tooltip/#API)。
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user