From 75b754de1dd96691c6dfd4af327444b86dcb786d Mon Sep 17 00:00:00 2001 From: Ferit Date: Fri, 23 Oct 2026 17:25:46 +0300 Subject: [PATCH] fix: support closable.disabled for close button --- src/Notification.tsx | 4 ++++ tests/index.test.tsx | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/Notification.tsx b/src/Notification.tsx index 0f68c54..6ac5270 100644 --- a/src/Notification.tsx +++ b/src/Notification.tsx @@ -153,6 +153,9 @@ const Notification = React.forwardRef((props, } function onInternalCloseClick(event: React.MouseEvent) { + if (closableConfig.disabled) { + return; + } event.preventDefault(); event.stopPropagation(); onInternalClose(); @@ -278,6 +281,7 @@ const Notification = React.forwardRef((props, type="button" className={clsx(`${noticePrefixCls}-close`, classNames?.close)} aria-label="Close" + disabled={closableConfig.disabled} {...closeBtnAriaProps} style={styles?.close} onClick={onInternalCloseClick} diff --git a/tests/index.test.tsx b/tests/index.test.tsx index ac34c84..8347d89 100644 --- a/tests/index.test.tsx +++ b/tests/index.test.tsx @@ -1213,6 +1213,32 @@ describe('Notification.Basic', () => { ).toEqual('close'); }); + it('Support disabled in closable', () => { + let closeCount = 0; + const { instance } = renderDemo({ + closable: { + disabled: true, + closeIcon: 'CloseBtn', + }, + }); + + act(() => { + instance.open({ + description:

1

, + duration: 0, + onClose: () => { + closeCount += 1; + }, + }); + }); + + const closeBtn = document.querySelector('.rc-notification-notice-close') as HTMLButtonElement; + expect(closeBtn.disabled).toBe(true); + + fireEvent.click(closeBtn); + expect(closeCount).toEqual(0); + }); + describe('showProgress', () => { it('show with progress', () => { const { instance } = renderDemo({