Skip to content

Commit 087bf6c

Browse files
authored
fix: onHeaderCell missing title (#929)
* test: test driven * fix: title missing
1 parent 12ddc99 commit 087bf6c

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

src/Cell/index.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,13 @@ function Cell<RecordType>(props: CellProps<RecordType>) {
176176
}
177177

178178
// >>>>> Title
179-
const title = getTitleFromCellRenderChildren({
180-
rowType,
181-
ellipsis,
182-
children: childNode,
183-
});
179+
const title =
180+
additionalProps.title ??
181+
getTitleFromCellRenderChildren({
182+
rowType,
183+
ellipsis,
184+
children: childNode,
185+
});
184186

185187
// >>>>> ClassName
186188
const mergedClassName = classNames(

tests/Cell.spec.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,25 @@ describe('Table.Cell', () => {
101101
wrapper.find('button').simulate('click');
102102
expect(wrapper.find('.rc-table-tbody .rc-table-cell').text()).toEqual('2');
103103
});
104+
105+
it('onHeaderCell', () => {
106+
const wrapper = mount(
107+
<Table
108+
columns={[
109+
{
110+
title: (
111+
<div>
112+
<p>NotYet</p>
113+
</div>
114+
),
115+
onHeaderCell: () => ({
116+
title: 'Bamboo',
117+
}),
118+
},
119+
]}
120+
/>,
121+
);
122+
123+
expect(wrapper.find('thead th').prop('title')).toEqual('Bamboo');
124+
});
104125
});

0 commit comments

Comments
 (0)