Skip to content

Commit

Permalink
popconfirm onVisibleChange should call with click event
Browse files Browse the repository at this point in the history
close #8614
  • Loading branch information
afc163 committed Sep 7, 2018
1 parent a4bc1f6 commit 02af089
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions components/popconfirm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import defaultLocale from '../locale-provider/default';

export interface PopconfirmProps extends AbstractTooltipProps {
title: React.ReactNode;
onConfirm?: (e: React.MouseEvent<any>) => void;
onCancel?: (e: React.MouseEvent<any>) => void;
onConfirm?: (e?: React.MouseEvent<any>) => void;
onCancel?: (e?: React.MouseEvent<any>) => void;
okText?: React.ReactNode;
okType?: ButtonType;
cancelText?: React.ReactNode;
icon?: React.ReactNode;
onVisibleChange?: (visible?: boolean, e?: React.MouseEvent<any>) => void;
}

export interface PopconfirmState {
Expand Down Expand Up @@ -58,7 +59,7 @@ class Popconfirm extends React.Component<PopconfirmProps, PopconfirmState> {
}

onConfirm = (e: React.MouseEvent<HTMLButtonElement>) => {
this.setVisible(false);
this.setVisible(false, e);

const { onConfirm } = this.props;
if (onConfirm) {
Expand All @@ -67,7 +68,7 @@ class Popconfirm extends React.Component<PopconfirmProps, PopconfirmState> {
}

onCancel = (e: React.MouseEvent<HTMLButtonElement>) => {
this.setVisible(false);
this.setVisible(false, e);

const { onCancel } = this.props;
if (onCancel) {
Expand All @@ -79,15 +80,15 @@ class Popconfirm extends React.Component<PopconfirmProps, PopconfirmState> {
this.setVisible(visible);
}

setVisible(visible: boolean) {
setVisible(visible: boolean, e?: React.MouseEvent<HTMLButtonElement>) {
const props = this.props;
if (!('visible' in props)) {
this.setState({ visible });
}

const { onVisibleChange } = props;
if (onVisibleChange) {
onVisibleChange(visible);
onVisibleChange(visible, e);
}
}

Expand Down

0 comments on commit 02af089

Please sign in to comment.