From 2453e2174417a3174a6f48fee6e32d0a47acfcba Mon Sep 17 00:00:00 2001 From: MadCcc <1075746765@qq.com> Date: Fri, 21 Oct 2022 10:16:03 +0800 Subject: [PATCH] fix: modal footer should be hidden if null (#38138) --- components/modal/PurePanel.tsx | 40 +++++++++---------- components/modal/__tests__/Modal.test.tsx | 5 +++ .../__snapshots__/Modal.test.tsx.snap | 20 ---------- components/popconfirm/style/index.tsx | 2 +- 4 files changed, 26 insertions(+), 41 deletions(-) diff --git a/components/modal/PurePanel.tsx b/components/modal/PurePanel.tsx index aa3db8a2d2..a04d6a68de 100644 --- a/components/modal/PurePanel.tsx +++ b/components/modal/PurePanel.tsx @@ -54,26 +54,26 @@ export function renderFooter( footer, } = props; - return ( - footer ?? ( - - {locale => ( - <> - - - - )} - - ) + return footer === undefined ? ( + + {locale => ( + <> + + + + )} + + ) : ( + footer ); } diff --git a/components/modal/__tests__/Modal.test.tsx b/components/modal/__tests__/Modal.test.tsx index 69d27b5948..6d52fee427 100644 --- a/components/modal/__tests__/Modal.test.tsx +++ b/components/modal/__tests__/Modal.test.tsx @@ -105,4 +105,9 @@ describe('Modal', () => { errSpy.mockRestore(); }); + + it('should not render footer if null', () => { + const { container } = render(); + expect(container.querySelector('.ant-modal-footer')).toBeFalsy(); + }); }); diff --git a/components/modal/__tests__/__snapshots__/Modal.test.tsx.snap b/components/modal/__tests__/__snapshots__/Modal.test.tsx.snap index fa50aedad9..a338796b52 100644 --- a/components/modal/__tests__/__snapshots__/Modal.test.tsx.snap +++ b/components/modal/__tests__/__snapshots__/Modal.test.tsx.snap @@ -155,26 +155,6 @@ exports[`Modal render without footer 1`] = ` > Here is content of Modal -