Skip to content

Commit

Permalink
fix(modal): fix modal onOk/onCancel method is not a valid function wh…
Browse files Browse the repository at this point in the history
…en there is a close parameter

closed: ant-design#36581
  • Loading branch information
Wxh16144 committed Jul 20, 2022
1 parent 3f8d058 commit 5326856
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion components/modal/confirm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import CheckCircleOutlined from '@ant-design/icons/CheckCircleOutlined';
import CloseCircleOutlined from '@ant-design/icons/CloseCircleOutlined';
import ExclamationCircleOutlined from '@ant-design/icons/ExclamationCircleOutlined';
import InfoCircleOutlined from '@ant-design/icons/InfoCircleOutlined';
import noop from 'lodash/noop';
import { render as reactRender, unmount as reactUnmount } from 'rc-util/lib/React/render';
import * as React from 'react';
import { globalConfig } from '../config-provider';
Expand Down Expand Up @@ -34,7 +35,7 @@ export default function confirm(config: ModalFuncProps) {
function destroy(...args: any[]) {
const triggerCancel = args.some(param => param && param.triggerCancel);
if (config.onCancel && triggerCancel) {
config.onCancel(...args);
config.onCancel(noop, ...args.slice(1));
}
for (let i = 0; i < destroyFns.length; i++) {
const fn = destroyFns[i];
Expand Down
3 changes: 2 additions & 1 deletion components/modal/useModal/HookModal.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import noop from 'lodash/noop';
import * as React from 'react';
import { ConfigContext } from '../../config-provider';
import LocaleReceiver from '../../locale-provider/LocaleReceiver';
Expand Down Expand Up @@ -36,7 +37,7 @@ const HookModal: React.ForwardRefRenderFunction<HookModalRef, HookModalProps> =
setVisible(false);
const triggerCancel = args.some(param => param && param.triggerCancel);
if (innerConfig.onCancel && triggerCancel) {
innerConfig.onCancel();
innerConfig.onCancel(noop, ...args.slice(1));
}
};

Expand Down

0 comments on commit 5326856

Please sign in to comment.