diff --git a/components/modal/Modal.tsx b/components/modal/Modal.tsx index 966376532c1901d38351b98cfa53f9921652f0ef..6cc3236809ae2a9f02038abf398b9449f7ddc500 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 6ad8f5414f7f3c09bd6ecc9f2d20509729ed69ee..526e2afd968a88a186f580385272faa827ba7b23 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 59750ddc518d7b0b514c15747344888420d0de54..cfef06f3cc617e719e55ff488e7379675eeb7b4a 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 36ab711a47c8c886018dc039b219bc9baf0e90d8..e8eb83afd81a157238dde4b8176d4c53569b3df3 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 c4f90d1cd0f06d2df2c30b9fb07d3618e767ec34..f95cd2ecaba60551c488ebc6b266cabfeb64b6d7 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 f75570cd2b93209eaac533d04d81f4aecdf0503f..ffe09127ca7fee9c9429232099875eeb6fd6168f 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 ce988824719376e8ae5508047ec729ece30e6247..be982260a651d9d2686ba5307704bcee583c9a27 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 42468effc50a392de7f4e6865d99ebdc90e09e18..2bded6d4f4bacca26f57febc63cde98e34b614ba 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 | 取消 |