mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 17:44:35 +08:00
* fix: Notification closeIcon don't update (#32351) * add test case for Notification closeIcon (#32351) Co-authored-by: shuzhiqiang <shuzhiqiang@megalinkps.cn>
This commit is contained in:
parent
6b56af466f
commit
27c3b51c18
@ -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: <span className={`test-customize-icon-${type}`} />,
|
||||
});
|
||||
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,
|
||||
|
@ -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 = (
|
||||
<span className={`${prefixCls}-close-x`}>
|
||||
{closeIcon || <CloseOutlined className={`${prefixCls}-close-icon`} />}
|
||||
</span>
|
||||
);
|
||||
|
||||
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 = (
|
||||
<span className={`${prefixCls}-close-x`}>
|
||||
{closeIcon || <CloseOutlined className={`${prefixCls}-close-icon`} />}
|
||||
</span>
|
||||
);
|
||||
|
||||
const autoMarginTag =
|
||||
!description && iconNode ? (
|
||||
<span className={`${prefixCls}-message-single-line-auto-margin`} />
|
||||
@ -247,6 +246,7 @@ function getRCNoticeProps(args: ArgsProps, prefixCls: string, iconPrefixCls?: st
|
||||
),
|
||||
duration,
|
||||
closable: true,
|
||||
closeIcon: closeIconToRender,
|
||||
onClose,
|
||||
onClick,
|
||||
key,
|
||||
|
Loading…
Reference in New Issue
Block a user