From 16bb5489e6de14deebad1269a90593b4f9c979a6 Mon Sep 17 00:00:00 2001 From: WeijieChen Date: Tue, 26 Oct 2021 19:12:08 +0800 Subject: [PATCH] feat: add showCancel prop for popconfirm (#32620) Co-authored-by: machixian --- components/popconfirm/index.en-US.md | 1 + components/popconfirm/index.tsx | 20 ++++++++++++++++---- components/popconfirm/index.zh-CN.md | 1 + 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/components/popconfirm/index.en-US.md b/components/popconfirm/index.en-US.md index 4960b6a678..c2e5314588 100644 --- a/components/popconfirm/index.en-US.md +++ b/components/popconfirm/index.en-US.md @@ -24,6 +24,7 @@ The difference with the `confirm` modal dialog is that it's more lightweight tha | okButtonProps | The ok button props | [ButtonProps](/components/button/#API) | - | | okText | The text of the Confirm button | string | `OK` | | okType | Button `type` of the Confirm button | string | `primary` | +| showCancel | Show cancel button | boolean | true | | title | The title of the confirmation box | ReactNode \| () => ReactNode | - | | onCancel | A callback of cancel | function(e) | - | | onConfirm | A callback of confirmation | function(e) | - | diff --git a/components/popconfirm/index.tsx b/components/popconfirm/index.tsx index f8cce04f30..1537e84eda 100644 --- a/components/popconfirm/index.tsx +++ b/components/popconfirm/index.tsx @@ -24,6 +24,7 @@ export interface PopconfirmProps extends AbstractTooltipProps { cancelText?: React.ReactNode; okButtonProps?: ButtonProps; cancelButtonProps?: ButtonProps; + showCancel?: boolean; icon?: React.ReactNode; onVisibleChange?: ( visible: boolean, @@ -82,7 +83,16 @@ const Popconfirm = React.forwardRef((props, ref) => { }; const renderOverlay = (prefixCls: string, popconfirmLocale: PopconfirmLocale) => { - const { okButtonProps, cancelButtonProps, title, cancelText, okText, okType, icon } = props; + const { + okButtonProps, + cancelButtonProps, + title, + cancelText, + okText, + okType, + icon, + showCancel = true, + } = props; return (
@@ -90,9 +100,11 @@ const Popconfirm = React.forwardRef((props, ref) => {
{getRenderPropValue(title)}
- + {showCancel && ( + + )} ReactNode | - | | onCancel | 点击取消的回调 | function(e) | - | | onConfirm | 点击确认的回调 | function(e) | - |