From 93a6ee1b40993d90ff20d6fc8119d89d47458eaf Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 25 Jun 2023 12:11:40 +0800 Subject: [PATCH] fix: notification should hide close icon when closeIcon={null} (#42791) --- .../notification/__tests__/index.test.tsx | 24 +++++++++++++++++++ components/notification/index.tsx | 13 ++++++---- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/components/notification/__tests__/index.test.tsx b/components/notification/__tests__/index.test.tsx index c62bed90ad..d7ff8fea09 100644 --- a/components/notification/__tests__/index.test.tsx +++ b/components/notification/__tests__/index.test.tsx @@ -272,6 +272,30 @@ describe('notification', () => { expect(document.querySelectorAll('.test-customize-icon').length).toBe(1); }); + it('support closeIcon to be null', () => { + act(() => { + notification.open({ + message: 'Notification Title', + duration: 0, + closeIcon: null, + }); + }); + + expect(document.querySelectorAll('.test-customize-icon').length).toBe(0); + }); + + it('support closeIcon to be false', () => { + act(() => { + notification.open({ + message: 'Notification Title', + duration: 0, + closeIcon: false, + }); + }); + + expect(document.querySelectorAll('.test-customize-icon').length).toBe(0); + }); + it('support config closeIcon', () => { notification.config({ closeIcon: , diff --git a/components/notification/index.tsx b/components/notification/index.tsx index c674a97827..d3d6bb90e5 100755 --- a/components/notification/index.tsx +++ b/components/notification/index.tsx @@ -252,11 +252,14 @@ function getRCNoticeProps(args: ArgsProps, prefixCls: string, iconPrefixCls?: st }); } - const closeIconToRender = ( - - {closeIcon || } - - ); + const closeIconToRender = + typeof closeIcon === 'undefined' ? ( + + + + ) : ( + closeIcon + ); const autoMarginTag = !description && iconNode ? (