Browse Source

test: fix Modal test cov agian (#41216)

* test: fix Modal footer test cov

* test: fix Modal footer test cov

* fix footer

* Update components/modal/PurePanel.tsx

Co-authored-by: MadCcc <1075746765@qq.com>

* fix footer

---------

Co-authored-by: MadCcc <1075746765@qq.com>
pull/41225/head
afc163 2 years ago
committed by GitHub
parent
commit
d70f599a7e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      components/modal/Modal.tsx
  2. 7
      components/modal/PurePanel.tsx

7
components/modal/Modal.tsx

@ -200,6 +200,9 @@ const Modal: React.FC<ModalProps> = (props) => {
warning(!('visible' in props), 'Modal', '`visible` is deprecated, please use `open` instead.');
}
const dialogFooter =
footer === undefined ? <Footer {...props} onOk={handleOk} onCancel={handleCancel} /> : footer;
return wrapSSR(
<NoCompactStyle>
<NoFormStyle status override>
@ -210,9 +213,7 @@ const Modal: React.FC<ModalProps> = (props) => {
prefixCls={prefixCls}
rootClassName={classNames(hashId, rootClassName)}
wrapClassName={wrapClassNameExtended}
footer={
footer === null ? footer : <Footer {...props} onOk={handleOk} onCancel={handleCancel} />
}
footer={dialogFooter}
visible={open ?? visible}
mousePosition={restProps.mousePosition ?? mousePosition}
onClose={handleCancel}

7
components/modal/PurePanel.tsx

@ -55,12 +55,11 @@ export const Footer: React.FC<
onCancel,
okButtonProps,
cancelButtonProps,
footer,
} = props;
const [locale] = useLocale('Modal', getConfirmLocale());
return footer === undefined ? (
return (
<>
<Button onClick={onCancel} {...cancelButtonProps}>
{cancelText || locale?.cancelText}
@ -74,8 +73,6 @@ export const Footer: React.FC<
{okText || locale?.okText}
</Button>
</>
) : (
(footer as React.ReactElement)
);
};
@ -119,7 +116,7 @@ const PurePanel: React.FC<PurePanelProps> = (props) => {
additionalProps = {
closable: closable ?? true,
title,
footer: <Footer {...props} />,
footer: props.footer === undefined ? <Footer {...props} /> : props.footer,
children,
};
}

Loading…
Cancel
Save