File tree 2 files changed +28
-2
lines changed 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -212,11 +212,13 @@ function Cell<RecordType>(props: CellProps<RecordType>) {
212
212
alignStyle . textAlign = align ;
213
213
}
214
214
215
+ // The order is important since user can overwrite style.
216
+ // For example ant-design/ant-design#51763
215
217
const mergedStyle = {
218
+ ...legacyCellProps ?. style ,
216
219
...fixedStyle ,
217
- ...additionalProps . style ,
218
220
...alignStyle ,
219
- ...legacyCellProps ? .style ,
221
+ ...additionalProps . style ,
220
222
} ;
221
223
222
224
// >>>>> Children Node
Original file line number Diff line number Diff line change @@ -122,4 +122,28 @@ describe('Table.Cell', () => {
122
122
123
123
expect ( wrapper . find ( 'thead th' ) . prop ( 'title' ) ) . toEqual ( 'Bamboo' ) ;
124
124
} ) ;
125
+
126
+ // https://github.com/ant-design/ant-design/issues/51763
127
+ it ( 'style merge order' , ( ) => {
128
+ const wrapper = mount (
129
+ < Table
130
+ columns = { [
131
+ {
132
+ align : 'center' ,
133
+ onHeaderCell : ( ) => ( {
134
+ style : {
135
+ color : 'red' ,
136
+ textAlign : 'end' , // overwrite align
137
+ } ,
138
+ } ) ,
139
+ } ,
140
+ ] }
141
+ /> ,
142
+ ) ;
143
+
144
+ expect ( wrapper . find ( 'thead th' ) . prop ( 'style' ) ) . toEqual ( {
145
+ color : 'red' ,
146
+ textAlign : 'end' ,
147
+ } ) ;
148
+ } ) ;
125
149
} ) ;
You can’t perform that action at this time.
0 commit comments