mirror of
https://github.com/ant-design/ant-design.git
synced 2026-02-09 02:49:18 +08:00
fix(Button): child element's className being cleared when rendering two Chinese characters. (#56593)
This commit is contained in:
@@ -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(
|
||||
<Button>
|
||||
<span className="custom-class" style={{ color: 'rgb(255, 0, 0)' }}>
|
||||
按钮
|
||||
</span>
|
||||
</Button>,
|
||||
);
|
||||
|
||||
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(<Button type="link">按钮</Button>);
|
||||
|
||||
@@ -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 },
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user