diff --git a/components/notification/__tests__/index.test.js b/components/notification/__tests__/index.test.js index 205c2aedf0..5391f8985b 100644 --- a/components/notification/__tests__/index.test.js +++ b/components/notification/__tests__/index.test.js @@ -191,6 +191,21 @@ describe('notification', () => { expect(document.querySelectorAll('.test-customize-icon').length).toBe(1); }); + it('closeIcon should be update', async () => { + const openNotificationWithCloseIcon = async type => { + notification.open({ + message: 'Notification Title', + closeIcon: , + }); + await Promise.resolve(); + expect(document.querySelectorAll(`.test-customize-icon-${type}`).length).toBe(1); + }; + + const promises = ['1', '2'].map(type => openNotificationWithCloseIcon(type)); + + await Promise.all(promises); + }); + it('support config duration', () => { notification.config({ duration: 0, diff --git a/components/notification/index.tsx b/components/notification/index.tsx index 345b5c65d7..0749758d4f 100755 --- a/components/notification/index.tsx +++ b/components/notification/index.tsx @@ -124,7 +124,6 @@ function getNotificationInstance( top, bottom, getContainer = defaultGetContainer, - closeIcon = defaultCloseIcon, prefixCls: customizePrefixCls, } = args; const { getPrefixCls, getIconPrefixCls } = globalConfig(); @@ -141,12 +140,6 @@ function getNotificationInstance( return; } - const closeIconToRender = ( - - {closeIcon || } - - ); - const notificationClass = classNames(`${prefixCls}-${placement}`, { [`${prefixCls}-rtl`]: rtl === true, }); @@ -158,7 +151,6 @@ function getNotificationInstance( className: notificationClass, style: getPlacementStyle(placement, top, bottom), getContainer, - closeIcon: closeIconToRender, maxCount, }, notification => { @@ -213,6 +205,7 @@ function getRCNoticeProps(args: ArgsProps, prefixCls: string, iconPrefixCls?: st key, style, className, + closeIcon = defaultCloseIcon, } = args; const duration = durationArg === undefined ? defaultDuration : durationArg; @@ -226,6 +219,12 @@ function getRCNoticeProps(args: ArgsProps, prefixCls: string, iconPrefixCls?: st }); } + const closeIconToRender = ( + + {closeIcon || } + + ); + const autoMarginTag = !description && iconNode ? ( @@ -247,6 +246,7 @@ function getRCNoticeProps(args: ArgsProps, prefixCls: string, iconPrefixCls?: st ), duration, closable: true, + closeIcon: closeIconToRender, onClose, onClick, key,