mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 17:44:35 +08:00
fix: Descriptions number 0 can't render span (#34696)
* fix: number 0 can't render span * Update Cell.tsx * chore: add test case
This commit is contained in:
parent
be18ea659b
commit
5588dae212
@ -60,7 +60,7 @@ const Cell: React.FC<CellProps> = ({
|
|||||||
colSpan={span}
|
colSpan={span}
|
||||||
>
|
>
|
||||||
<div className={`${itemPrefixCls}-item-container`}>
|
<div className={`${itemPrefixCls}-item-container`}>
|
||||||
{label && (
|
{(label || label === 0) && (
|
||||||
<span
|
<span
|
||||||
className={classNames(`${itemPrefixCls}-item-label`, {
|
className={classNames(`${itemPrefixCls}-item-label`, {
|
||||||
[`${itemPrefixCls}-item-no-colon`]: !colon,
|
[`${itemPrefixCls}-item-no-colon`]: !colon,
|
||||||
@ -70,7 +70,7 @@ const Cell: React.FC<CellProps> = ({
|
|||||||
{label}
|
{label}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{content && (
|
{(content || content === 0) && (
|
||||||
<span className={classNames(`${itemPrefixCls}-item-content`)} style={contentStyle}>
|
<span className={classNames(`${itemPrefixCls}-item-content`)} style={contentStyle}>
|
||||||
{content}
|
{content}
|
||||||
</span>
|
</span>
|
||||||
|
@ -209,6 +209,46 @@ exports[`Descriptions column is number 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`Descriptions number 0 should render correct 1`] = `
|
||||||
|
<div
|
||||||
|
class="ant-descriptions"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-descriptions-view"
|
||||||
|
>
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr
|
||||||
|
class="ant-descriptions-row"
|
||||||
|
>
|
||||||
|
<td
|
||||||
|
class="ant-descriptions-item"
|
||||||
|
colspan="1"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="ant-descriptions-item-container"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="ant-descriptions-item-label"
|
||||||
|
style="color: red;"
|
||||||
|
>
|
||||||
|
0
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
class="ant-descriptions-item-content"
|
||||||
|
style="color: red;"
|
||||||
|
>
|
||||||
|
0
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`Descriptions should work with React Fragment 1`] = `
|
exports[`Descriptions should work with React Fragment 1`] = `
|
||||||
<div
|
<div
|
||||||
class="ant-descriptions"
|
class="ant-descriptions"
|
||||||
|
@ -238,4 +238,15 @@ describe('Descriptions', () => {
|
|||||||
wrapper.setProps({ extra: undefined });
|
wrapper.setProps({ extra: undefined });
|
||||||
expect(wrapper.find('.ant-descriptions-extra').exists()).toBe(false);
|
expect(wrapper.find('.ant-descriptions-extra').exists()).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('number 0 should render correct', () => {
|
||||||
|
const wrapper = mount(
|
||||||
|
<Descriptions>
|
||||||
|
<Descriptions.Item label={0} labelStyle={{ color: 'red' }} contentStyle={{ color: 'red' }}>
|
||||||
|
{0}
|
||||||
|
</Descriptions.Item>
|
||||||
|
</Descriptions>,
|
||||||
|
);
|
||||||
|
expect(wrapper.render()).toMatchSnapshot();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user