mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-11-30 02:59:04 +08:00
fix: Desctiption miss style when value is number 0 (#21901)
* fix: Desctiption miss style when value is number 0 * fix test case
This commit is contained in:
parent
3de412353f
commit
4b0effbc0e
@ -1,6 +1,10 @@
|
||||
import * as React from 'react';
|
||||
import classNames from 'classnames';
|
||||
|
||||
function notEmpty(val: any) {
|
||||
return val !== undefined && val !== null;
|
||||
}
|
||||
|
||||
export interface CellProps {
|
||||
itemPrefixCls: string;
|
||||
span: number;
|
||||
@ -31,15 +35,15 @@ const Cell: React.FC<CellProps> = ({
|
||||
<Component
|
||||
className={classNames(
|
||||
{
|
||||
[`${itemPrefixCls}-item-label`]: label,
|
||||
[`${itemPrefixCls}-item-content`]: content,
|
||||
[`${itemPrefixCls}-item-label`]: notEmpty(label),
|
||||
[`${itemPrefixCls}-item-content`]: notEmpty(content),
|
||||
},
|
||||
className,
|
||||
)}
|
||||
style={style}
|
||||
colSpan={span}
|
||||
>
|
||||
{label || content}
|
||||
{notEmpty(label) ? label : content}
|
||||
</Component>
|
||||
);
|
||||
}
|
||||
|
@ -216,4 +216,15 @@ describe('Descriptions', () => {
|
||||
matchSpan(2, [2, 2]);
|
||||
matchSpan(4, [3, 1]);
|
||||
});
|
||||
|
||||
it('number value should render correct', () => {
|
||||
const wrapper = mount(
|
||||
<Descriptions bordered>
|
||||
<Descriptions.Item label={0}>{0}</Descriptions.Item>
|
||||
</Descriptions>,
|
||||
);
|
||||
|
||||
expect(wrapper.find('th').hasClass('ant-descriptions-item-label')).toBeTruthy();
|
||||
expect(wrapper.find('td').hasClass('ant-descriptions-item-content')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user