Skip to content

Commit 0f11e4e

Browse files
committed
fix: descriptionsItem labelStyle not work, close #5920
1 parent d48cd8e commit 0f11e4e

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

components/descriptions/Row.tsx

+16-17
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import Cell from './Cell';
22
import { getSlot, getClass, getStyle } from '../_util/props-util';
3-
import type { FunctionalComponent, VNode } from 'vue';
3+
import type { CSSProperties, FunctionalComponent, VNode } from 'vue';
44
import { inject, ref } from 'vue';
5-
import type { DescriptionsContextProp } from './index';
65
import { descriptionsContext } from './index';
76

87
interface CellConfig {
@@ -32,29 +31,29 @@ const Row: FunctionalComponent<RowProps> = props => {
3231
showContent,
3332
labelStyle: rootLabelStyle,
3433
contentStyle: rootContentStyle,
35-
}: CellConfig & DescriptionsContextProp,
34+
}: CellConfig & { labelStyle?: CSSProperties; contentStyle?: CSSProperties },
3635
) => {
3736
return items.map((item, index) => {
37+
const itemProps = item.props || {};
3838
const {
3939
prefixCls: itemPrefixCls = prefixCls,
4040
span = 1,
41-
labelStyle,
42-
contentStyle,
41+
labelStyle = itemProps['label-style'],
42+
contentStyle = itemProps['content-style'],
4343
label = (item.children as any)?.label?.(),
44-
} = item.props || {};
44+
} = itemProps;
4545
const children = getSlot(item);
4646
const className = getClass(item);
4747
const style = getStyle(item);
4848
const { key } = item;
49-
5049
if (typeof component === 'string') {
5150
return (
5251
<Cell
5352
key={`${type}-${String(key) || index}`}
5453
class={className}
5554
style={style}
56-
labelStyle={{ ...rootLabelStyle.value, ...labelStyle }}
57-
contentStyle={{ ...rootContentStyle.value, ...contentStyle }}
55+
labelStyle={{ ...rootLabelStyle, ...labelStyle }}
56+
contentStyle={{ ...rootContentStyle, ...contentStyle }}
5857
span={span}
5958
colon={colon}
6059
component={component}
@@ -70,7 +69,7 @@ const Row: FunctionalComponent<RowProps> = props => {
7069
<Cell
7170
key={`label-${String(key) || index}`}
7271
class={className}
73-
style={{ ...rootLabelStyle.value, ...style, ...labelStyle }}
72+
style={{ ...rootLabelStyle, ...style, ...labelStyle }}
7473
span={1}
7574
colon={colon}
7675
component={component[0]}
@@ -81,7 +80,7 @@ const Row: FunctionalComponent<RowProps> = props => {
8180
<Cell
8281
key={`content-${String(key) || index}`}
8382
class={className}
84-
style={{ ...rootContentStyle.value, ...style, ...contentStyle }}
83+
style={{ ...rootContentStyle, ...style, ...contentStyle }}
8584
span={span * 2 - 1}
8685
component={component[1]}
8786
itemPrefixCls={itemPrefixCls}
@@ -105,17 +104,17 @@ const Row: FunctionalComponent<RowProps> = props => {
105104
component: 'th',
106105
type: 'label',
107106
showLabel: true,
108-
labelStyle,
109-
contentStyle,
107+
labelStyle: labelStyle.value,
108+
contentStyle: contentStyle.value,
110109
})}
111110
</tr>
112111
<tr key={`content-${index}`} class={`${prefixCls}-row`}>
113112
{renderCells(row, props, {
114113
component: 'td',
115114
type: 'content',
116115
showContent: true,
117-
labelStyle,
118-
contentStyle,
116+
labelStyle: labelStyle.value,
117+
contentStyle: contentStyle.value,
119118
})}
120119
</tr>
121120
</>
@@ -129,8 +128,8 @@ const Row: FunctionalComponent<RowProps> = props => {
129128
type: 'item',
130129
showLabel: true,
131130
showContent: true,
132-
labelStyle,
133-
contentStyle,
131+
labelStyle: labelStyle.value,
132+
contentStyle: contentStyle.value,
134133
})}
135134
</tr>
136135
);

0 commit comments

Comments
 (0)