From e07cdf5387a5a8f71253372e0319ecd008ee15d0 Mon Sep 17 00:00:00 2001 From: ddcat1115 Date: Fri, 24 Feb 2017 16:07:39 +0800 Subject: [PATCH] add left out event parameters for Modal[onOk] Popconfirm[onConfirm] Popconfirm[onCancel] (#5042) --- components/modal/Modal.tsx | 6 +++--- components/modal/demo/basic.md | 4 ++-- components/modal/index.en-US.md | 2 +- components/modal/index.zh-CN.md | 2 +- components/popconfirm/demo/basic.md | 6 ++++-- components/popconfirm/index.en-US.md | 4 ++-- components/popconfirm/index.tsx | 12 ++++++------ components/popconfirm/index.zh-CN.md | 4 ++-- 8 files changed, 21 insertions(+), 19 deletions(-) diff --git a/components/modal/Modal.tsx b/components/modal/Modal.tsx index 966376532c..6cc3236809 100644 --- a/components/modal/Modal.tsx +++ b/components/modal/Modal.tsx @@ -17,7 +17,7 @@ export interface ModalProps { /** 是否显示右上角的关闭按钮*/ closable?: boolean; /** 点击确定回调*/ - onOk?: () => void; + onOk?: (e: React.MouseEvent) => void; /** 点击模态框右上角叉、取消按钮、Props.maskClosable 值为 true 时的遮罩层或键盘按下 Esc 时的回调*/ onCancel?: (e: React.MouseEvent) => void; afterClose?: () => void; @@ -89,10 +89,10 @@ export default class Modal extends React.Component { } } - handleOk = () => { + handleOk = (e) => { const onOk = this.props.onOk; if (onOk) { - onOk(); + onOk(e); } } diff --git a/components/modal/demo/basic.md b/components/modal/demo/basic.md index 6ad8f5414f..526e2afd96 100644 --- a/components/modal/demo/basic.md +++ b/components/modal/demo/basic.md @@ -23,8 +23,8 @@ class App extends React.Component { visible: true, }); } - handleOk = () => { - console.log('Clicked OK'); + handleOk = (e) => { + console.log(e); this.setState({ visible: false, }); diff --git a/components/modal/index.en-US.md b/components/modal/index.en-US.md index 59750ddc51..cfef06f3cc 100644 --- a/components/modal/index.en-US.md +++ b/components/modal/index.en-US.md @@ -22,7 +22,7 @@ and so on. | confirmLoading | Determine whether to apply loading visual effect for OK button or not | boolean | no | | title | The modal dialog's title | string\|ReactNode | no | | closable | Determine whether a close (x) button is visible on top right of the modal dialog or not | boolean | true | -| onOk | Specify a function that will be called when a user clicked OK button | function | no | +| onOk | Specify a function that will be called when a user clicked OK button | function(e) | no | | onCancel | Specify a function that will be called when a user clicked mask, close button on top right or cancel button | function(e) | no | | width | Width of a modal dialog | string\|number | 520 | | footer | Footer content, set as `footer={null}` when you don't need default buttons | string\|ReactNode | OK and cancel button | diff --git a/components/modal/index.zh-CN.md b/components/modal/index.zh-CN.md index 36ab711a47..e8eb83afd8 100644 --- a/components/modal/index.zh-CN.md +++ b/components/modal/index.zh-CN.md @@ -21,7 +21,7 @@ title: Modal | confirmLoading | 确定按钮 loading | boolean | 无 | | title | 标题 | string\|ReactNode | 无 | | closable | 是否显示右上角的关闭按钮 | boolean | true | -| onOk | 点击确定回调 | function | 无 | +| onOk | 点击确定回调 | function(e) | 无 | | onCancel | 点击遮罩层或右上角叉或取消按钮的回调 | function(e) | 无 | | width | 宽度 | string\|number | 520 | | footer | 底部内容,当不需要默认底部按钮时,可以设为 `footer={null}` | string\|ReactNode | 确定取消按钮 | diff --git a/components/popconfirm/demo/basic.md b/components/popconfirm/demo/basic.md index c4f90d1cd0..f95cd2ecab 100755 --- a/components/popconfirm/demo/basic.md +++ b/components/popconfirm/demo/basic.md @@ -16,11 +16,13 @@ The basic example. ````jsx import { Popconfirm, message } from 'antd'; -function confirm() { +function confirm(e) { + console.log(e); message.success('Click on Yes'); } -function cancel() { +function cancel(e) { + console.log(e); message.error('Click on No'); } diff --git a/components/popconfirm/index.en-US.md b/components/popconfirm/index.en-US.md index f75570cd2b..ffe09127ca 100644 --- a/components/popconfirm/index.en-US.md +++ b/components/popconfirm/index.en-US.md @@ -17,8 +17,8 @@ The difference with `confirm` is more lightweight than the static popped full-sc | Param | Description | Type | Default value | |-----------|------------------------------------------|---------------|--------| | title | title of the confirmation box | string\|ReactNode | none | -| onConfirm | callback of confirmation | function | none | -| onCancel | callback of cancel | function | none | +| onConfirm | callback of confirmation | function(e) | none | +| onCancel | callback of cancel | function(e) | none | | okText | text of the confirmation button | string | Confirm | | cancelText| text of the cancel button | string | Cancel | diff --git a/components/popconfirm/index.tsx b/components/popconfirm/index.tsx index ce98882471..be982260a6 100644 --- a/components/popconfirm/index.tsx +++ b/components/popconfirm/index.tsx @@ -6,8 +6,8 @@ import Button from '../button'; export interface PopconfirmProps extends AbstractTooltipProps { title: React.ReactNode; - onConfirm?: () => void; - onCancel?: () => void; + onConfirm?: (e: React.MouseEvent) => void; + onCancel?: (e: React.MouseEvent) => void; okText?: React.ReactNode; cancelText?: React.ReactNode; } @@ -46,21 +46,21 @@ export default class Popconfirm extends React.Component { } } - confirm = () => { + confirm = (e) => { this.setVisible(false); const onConfirm = this.props.onConfirm; if (onConfirm) { - onConfirm.call(this); + onConfirm.call(this, e); } } - cancel = () => { + cancel = (e) => { this.setVisible(false); const onCancel = this.props.onCancel; if (onCancel) { - onCancel.call(this); + onCancel.call(this, e); } } diff --git a/components/popconfirm/index.zh-CN.md b/components/popconfirm/index.zh-CN.md index 42468effc5..2bded6d4f4 100644 --- a/components/popconfirm/index.zh-CN.md +++ b/components/popconfirm/index.zh-CN.md @@ -18,8 +18,8 @@ title: Popconfirm | 参数 | 说明 | 类型 | 默认值 | |-----------|------------------------------------------|---------------|--------| | title | 确认框的描述 | string\|ReactNode | 无 | -| onConfirm | 点击确认的回调 | function | 无 | -| onCancel | 点击取消的回调 | function | 无 | +| onConfirm | 点击确认的回调 | function(e) | 无 | +| onCancel | 点击取消的回调 | function(e) | 无 | | okText | 确认按钮文字 | string | 确定 | | cancelText| 取消按钮文字 | string | 取消 |