From 4320e8dc767ff6386be075830f5252b5f69b5a6b Mon Sep 17 00:00:00 2001 From: tanjinzhou <415800467@qq.com> Date: Wed, 29 Jul 2020 17:05:59 +0800 Subject: [PATCH] fix: descriptions label not work --- antdv-demo | 2 +- components/descriptions/Col.jsx | 14 +++++++------- .../__tests__/__snapshots__/index.test.js.snap | 8 +++++++- components/descriptions/__tests__/index.test.js | 7 +------ components/descriptions/index.jsx | 3 +++ examples/App.vue | 2 +- 6 files changed, 20 insertions(+), 16 deletions(-) diff --git a/antdv-demo b/antdv-demo index 2cbc6d48f..be0a3b6de 160000 --- a/antdv-demo +++ b/antdv-demo @@ -1 +1 @@ -Subproject commit 2cbc6d48fd3de73954f1cb9689d9ac5b2dd8355c +Subproject commit be0a3b6de3866c09e82c6e7e66b6db5932142f49 diff --git a/components/descriptions/Col.jsx b/components/descriptions/Col.jsx index bf58f685e..a3ce36fe0 100644 --- a/components/descriptions/Col.jsx +++ b/components/descriptions/Col.jsx @@ -3,8 +3,8 @@ import { getOptionProps } from '../_util/props-util'; const Col = (_, { attrs }) => { const { child = {}, bordered, colon, type, layout, colKey: key } = attrs; const { prefixCls, span = 1 } = getOptionProps(child); - const { children = {} } = child; - const label = children.label && children.label(); + const { children = {}, props = {} } = child; + const label = props.label || (children.label && children.label()); const defaultSlot = children.default && children.default(); const labelProps = { @@ -19,7 +19,7 @@ const Col = (_, { attrs }) => { }; if (layout === 'vertical') { - labelProps.colSpan = span * 2 - 1; + labelProps.colspan = span * 2 - 1; } if (bordered) { @@ -27,7 +27,7 @@ const Col = (_, { attrs }) => { return {label}; } return ( - + {defaultSlot} ); @@ -35,7 +35,7 @@ const Col = (_, { attrs }) => { if (layout === 'vertical') { if (type === 'content') { return ( - + {defaultSlot} @@ -43,7 +43,7 @@ const Col = (_, { attrs }) => { ); } return ( - + { ); } return ( - + {label} {defaultSlot} diff --git a/components/descriptions/__tests__/__snapshots__/index.test.js.snap b/components/descriptions/__tests__/__snapshots__/index.test.js.snap index 732faa92d..23b077b59 100644 --- a/components/descriptions/__tests__/__snapshots__/index.test.js.snap +++ b/components/descriptions/__tests__/__snapshots__/index.test.js.snap @@ -2,6 +2,7 @@ exports[`Descriptions Descriptions support colon 1`] = `
+
@@ -16,11 +17,12 @@ exports[`Descriptions Descriptions support colon 1`] = ` exports[`Descriptions Descriptions support style 1`] = `
+
- +
Cloud DatabaseCloud Database
@@ -30,6 +32,7 @@ exports[`Descriptions Descriptions support style 1`] = ` exports[`Descriptions Descriptions.Item support className 1`] = `
+
@@ -44,6 +47,7 @@ exports[`Descriptions Descriptions.Item support className 1`] = ` exports[`Descriptions column is number 1`] = `
+
@@ -63,6 +67,7 @@ exports[`Descriptions column is number 1`] = ` exports[`Descriptions vertical layout 1`] = `
+
@@ -90,6 +95,7 @@ exports[`Descriptions vertical layout 1`] = ` exports[`Descriptions when item is rendered conditionally 1`] = `
+
diff --git a/components/descriptions/__tests__/index.test.js b/components/descriptions/__tests__/index.test.js index 2a25d4e9d..676685d6c 100644 --- a/components/descriptions/__tests__/index.test.js +++ b/components/descriptions/__tests__/index.test.js @@ -61,7 +61,7 @@ describe('Descriptions', () => { const wrapper = mount({ render() { return ( - + Cloud Database Prepaid 18:00:00 @@ -225,10 +225,5 @@ describe('Descriptions', () => { enquire.callunmatch(); wrapper.unmount(); - - await asyncExpect(() => {}); - await asyncExpect(() => {}); - await asyncExpect(() => {}); - await asyncExpect(() => {}); }); }); diff --git a/components/descriptions/index.jsx b/components/descriptions/index.jsx index 4073d25e2..1f1a7bcdc 100644 --- a/components/descriptions/index.jsx +++ b/components/descriptions/index.jsx @@ -31,6 +31,9 @@ function toArray(value) { export const DescriptionsItem = { name: 'ADescriptionsItem', props: initDefaultProps(DescriptionsItemProps, { span: 1 }), + render() { + return null; + }, }; export const DescriptionsProps = { diff --git a/examples/App.vue b/examples/App.vue index 2eddeda23..cbcfc2054 100644 --- a/examples/App.vue +++ b/examples/App.vue @@ -4,7 +4,7 @@