Browse Source

fix: notification should hide close icon when closeIcon={null} (#42791)

pull/43179/head
afc163 1 year ago
committed by GitHub
parent
commit
93a6ee1b40
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 24
      components/notification/__tests__/index.test.tsx
  2. 13
      components/notification/index.tsx

24
components/notification/__tests__/index.test.tsx

@ -272,6 +272,30 @@ describe('notification', () => {
expect(document.querySelectorAll('.test-customize-icon').length).toBe(1); 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', () => { it('support config closeIcon', () => {
notification.config({ notification.config({
closeIcon: <span className="test-customize-icon" />, closeIcon: <span className="test-customize-icon" />,

13
components/notification/index.tsx

@ -252,11 +252,14 @@ function getRCNoticeProps(args: ArgsProps, prefixCls: string, iconPrefixCls?: st
}); });
} }
const closeIconToRender = ( const closeIconToRender =
<span className={`${prefixCls}-close-x`}> typeof closeIcon === 'undefined' ? (
{closeIcon || <CloseOutlined className={`${prefixCls}-close-icon`} />} <span className={`${prefixCls}-close-x`}>
</span> <CloseOutlined className={`${prefixCls}-close-icon`} />
); </span>
) : (
closeIcon
);
const autoMarginTag = const autoMarginTag =
!description && iconNode ? ( !description && iconNode ? (

Loading…
Cancel
Save