diff --git a/src/dialog/DialogCard.tsx b/src/dialog/DialogCard.tsx index 5498f1a3db..42de883326 100644 --- a/src/dialog/DialogCard.tsx +++ b/src/dialog/DialogCard.tsx @@ -67,11 +67,7 @@ const DialogCard = forwardRef((props, ref) => { ...otherProps } = useDefaultProps(props, dialogCardDefaultProps); - const renderHeader = () => { - if (!header) { - return null; - } - + const renderHeaderContent = () => { const iconMap = { info: , warning: , @@ -109,11 +105,14 @@ const DialogCard = forwardRef((props, ref) => { ); }; - const renderFooter = () => { - if (footer === false || footer === null) { - return null; - } + const renderHeader = () => ( +
+ {renderHeaderContent()} + {renderCloseBtn()} +
+ ); + const renderFooter = () => { const defaultFooter = () => { const renderCancelBtn = renderDialogButton(cancelBtn, { variant: 'outline', @@ -138,12 +137,9 @@ const DialogCard = forwardRef((props, ref) => { return (
-
- {renderHeader()} - {renderCloseBtn()} -
+ {!!header && renderHeader()}
{body || children}
- {renderFooter()} + {!!footer && renderFooter()}
); }); diff --git a/src/dialog/__tests__/dialog.test.tsx b/src/dialog/__tests__/dialog.test.tsx index 0860e4d150..0c5bc08632 100644 --- a/src/dialog/__tests__/dialog.test.tsx +++ b/src/dialog/__tests__/dialog.test.tsx @@ -177,4 +177,14 @@ describe('Dialog组件测试', () => { fireEvent.click(document.querySelector('#test')); await mockTimeout(() => expect(document.querySelector('.t-dialog__modal')).not.toBeInTheDocument(), 400); }); + + test('Dislog props.header render', async () => { + const { container } = render( + +

This is a dialog

+
, + ); + + expect(container.querySelector('.t-dialog__header')).toBeNull(); + }); });