From 8fd30ab4a201e167fb2c88723feb8752ee845803 Mon Sep 17 00:00:00 2001 From: QdabuliuQ <69883552+QdabuliuQ@users.noreply.github.com> Date: Tue, 13 Jan 2026 18:14:54 +0800 Subject: [PATCH] fix(Button): child element's className being cleared when rendering two Chinese characters. (#56593) --- components/button/__tests__/index.test.tsx | 17 +++++++++++++++++ components/button/buttonHelpers.tsx | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/components/button/__tests__/index.test.tsx b/components/button/__tests__/index.test.tsx index 9b73a56c2d..3d34dc005e 100644 --- a/components/button/__tests__/index.test.tsx +++ b/components/button/__tests__/index.test.tsx @@ -115,6 +115,23 @@ describe('Button', () => { expect(container.querySelector('.ant-btn')).toHaveClass('ant-btn-two-chinese-chars'); }); + // https://github.com/ant-design/ant-design/issues/56591 + it('should preserve className when rendering two Chinese characters in child element', () => { + const { container } = render( + , + ); + + const span = container.querySelector('span.custom-class'); + expect(span).toBeTruthy(); + expect(span).toHaveClass('custom-class'); + expect(span).toHaveStyle({ color: 'rgb(255, 0, 0)' }); + expect(span).toHaveTextContent('按 钮'); + }); + // https://github.com/ant-design/ant-design/issues/18118 it('should not insert space to link or text button', () => { const wrapper1 = render(); diff --git a/components/button/buttonHelpers.tsx b/components/button/buttonHelpers.tsx index 06ee6ec218..8522661e5c 100644 --- a/components/button/buttonHelpers.tsx +++ b/components/button/buttonHelpers.tsx @@ -54,8 +54,8 @@ function splitCNCharsBySpace( return cloneElement(child, (oriProps) => ({ ...oriProps, children: oriProps.children.split('').join(SPACE), - className, - style, + className: clsx(oriProps.className, className) || undefined, + style: { ...oriProps.style, ...style }, })); }