mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 02:59:58 +08:00
add left out event parameters for Modal[onOk] Popconfirm[onConfirm] Popconfirm[onCancel] (#5042)
This commit is contained in:
parent
88100a29a3
commit
e07cdf5387
@ -17,7 +17,7 @@ export interface ModalProps {
|
||||
/** 是否显示右上角的关闭按钮*/
|
||||
closable?: boolean;
|
||||
/** 点击确定回调*/
|
||||
onOk?: () => void;
|
||||
onOk?: (e: React.MouseEvent<any>) => void;
|
||||
/** 点击模态框右上角叉、取消按钮、Props.maskClosable 值为 true 时的遮罩层或键盘按下 Esc 时的回调*/
|
||||
onCancel?: (e: React.MouseEvent<any>) => void;
|
||||
afterClose?: () => void;
|
||||
@ -89,10 +89,10 @@ export default class Modal extends React.Component<ModalProps, any> {
|
||||
}
|
||||
}
|
||||
|
||||
handleOk = () => {
|
||||
handleOk = (e) => {
|
||||
const onOk = this.props.onOk;
|
||||
if (onOk) {
|
||||
onOk();
|
||||
onOk(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
});
|
||||
|
@ -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 |
|
||||
|
@ -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 | 确定取消按钮 |
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
|
@ -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 |
|
||||
|
||||
|
@ -6,8 +6,8 @@ import Button from '../button';
|
||||
|
||||
export interface PopconfirmProps extends AbstractTooltipProps {
|
||||
title: React.ReactNode;
|
||||
onConfirm?: () => void;
|
||||
onCancel?: () => void;
|
||||
onConfirm?: (e: React.MouseEvent<any>) => void;
|
||||
onCancel?: (e: React.MouseEvent<any>) => void;
|
||||
okText?: React.ReactNode;
|
||||
cancelText?: React.ReactNode;
|
||||
}
|
||||
@ -46,21 +46,21 @@ export default class Popconfirm extends React.Component<PopconfirmProps, any> {
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,8 +18,8 @@ title: Popconfirm
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
|-----------|------------------------------------------|---------------|--------|
|
||||
| title | 确认框的描述 | string\|ReactNode | 无 |
|
||||
| onConfirm | 点击确认的回调 | function | 无 |
|
||||
| onCancel | 点击取消的回调 | function | 无 |
|
||||
| onConfirm | 点击确认的回调 | function(e) | 无 |
|
||||
| onCancel | 点击取消的回调 | function(e) | 无 |
|
||||
| okText | 确认按钮文字 | string | 确定 |
|
||||
| cancelText| 取消按钮文字 | string | 取消 |
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user