Browse Source
fix: notification should hide close icon when closeIcon={null} (#42791)
pull/43179/head
afc163
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
32 additions and
5 deletions
-
components/notification/__tests__/index.test.tsx
-
components/notification/index.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: <span className="test-customize-icon" />, |
|
|
|
|
|
@ -252,11 +252,14 @@ function getRCNoticeProps(args: ArgsProps, prefixCls: string, iconPrefixCls?: st |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
const closeIconToRender = ( |
|
|
|
<span className={`${prefixCls}-close-x`}> |
|
|
|
{closeIcon || <CloseOutlined className={`${prefixCls}-close-icon`} />} |
|
|
|
</span> |
|
|
|
); |
|
|
|
const closeIconToRender = |
|
|
|
typeof closeIcon === 'undefined' ? ( |
|
|
|
<span className={`${prefixCls}-close-x`}> |
|
|
|
<CloseOutlined className={`${prefixCls}-close-icon`} /> |
|
|
|
</span> |
|
|
|
) : ( |
|
|
|
closeIcon |
|
|
|
); |
|
|
|
|
|
|
|
const autoMarginTag = |
|
|
|
!description && iconNode ? ( |
|
|
|