Browse Source
Merge pull request #17337 from kairi1227/master
fix: Descriptions组件不设置label的显示问题
pull/17345/head
偏右
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
22 additions and
3 deletions
-
components/descriptions/__tests__/index.test.js
-
components/descriptions/index.tsx
-
components/descriptions/style/index.less
|
|
@ -42,9 +42,11 @@ describe('Descriptions', () => { |
|
|
|
<Descriptions.Item label="Billing">Prepaid</Descriptions.Item> |
|
|
|
<Descriptions.Item label="time">18:00:00</Descriptions.Item> |
|
|
|
<Descriptions.Item label="Amount">$80.00</Descriptions.Item> |
|
|
|
<Descriptions.Item>No-Label</Descriptions.Item> |
|
|
|
</Descriptions>, |
|
|
|
); |
|
|
|
expect(wrapper.find('tr')).toHaveLength(4); |
|
|
|
expect(wrapper.find('tr')).toHaveLength(5); |
|
|
|
expect(wrapper.find('.ant-descriptions-item-no-label')).toHaveLength(1); |
|
|
|
|
|
|
|
enquire.callunmatch(); |
|
|
|
wrapper.unmount(); |
|
|
|
|
|
@ -82,7 +82,12 @@ const renderCol = (child: React.ReactElement<DescriptionsItemProps>, bordered: b |
|
|
|
const { prefixCls, label, className, children, span = 1 } = child.props; |
|
|
|
if (bordered) { |
|
|
|
return [ |
|
|
|
<th className={classNames(`${prefixCls}-item-label`, className)} key="label"> |
|
|
|
<th |
|
|
|
className={classNames(`${prefixCls}-item-label`, className, { |
|
|
|
[`${prefixCls}-item-no-label`]: !label, |
|
|
|
})} |
|
|
|
key="label" |
|
|
|
> |
|
|
|
{label} |
|
|
|
</th>, |
|
|
|
<td |
|
|
@ -96,7 +101,12 @@ const renderCol = (child: React.ReactElement<DescriptionsItemProps>, bordered: b |
|
|
|
} |
|
|
|
return ( |
|
|
|
<td colSpan={span} className={classNames(`${prefixCls}-item`, className)}> |
|
|
|
<span className={`${prefixCls}-item-label`} key="label"> |
|
|
|
<span |
|
|
|
className={classNames(`${prefixCls}-item-label`, { |
|
|
|
[`${prefixCls}-item-no-label`]: !label, |
|
|
|
})} |
|
|
|
key="label" |
|
|
|
> |
|
|
|
{label} |
|
|
|
</span> |
|
|
|
<span className={`${prefixCls}-item-content`} key="content"> |
|
|
|
|
|
@ -51,6 +51,13 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
&-item-no-label { |
|
|
|
&::after { |
|
|
|
content: ''; |
|
|
|
margin: 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
&-item-content { |
|
|
|
display: table-cell; |
|
|
|
color: @text-color; |
|
|
|