Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Cell/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,13 @@ function Cell<RecordType>(props: CellProps<RecordType>) {
alignStyle.textAlign = align;
}

// The order is important since user can overwrite style.
// For example ant-design/ant-design#51763
const mergedStyle = {
...legacyCellProps?.style,
...fixedStyle,
...additionalProps.style,
...alignStyle,
...legacyCellProps?.style,
...additionalProps.style,
};

// >>>>> Children Node
Expand Down
24 changes: 24 additions & 0 deletions tests/Cell.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,28 @@ describe('Table.Cell', () => {

expect(wrapper.find('thead th').prop('title')).toEqual('Bamboo');
});

// https://github.com/ant-design/ant-design/issues/51763
it('style merge order', () => {
const wrapper = mount(
<Table
columns={[
{
align: 'center',
onHeaderCell: () => ({
style: {
color: 'red',
textAlign: 'end', // overwrite align
},
}),
},
]}
/>,
);

expect(wrapper.find('thead th').prop('style')).toEqual({
color: 'red',
textAlign: 'end',
});
});
});