Skip to content

Commit 1936e9a

Browse files
committed
fix: INTERNAL_COL_DEFINE should work on header table
ref ant-design/ant-design#23799
1 parent cb17d38 commit 1936e9a

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

src/Header/FixedHeader.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ function FixedHeader<RecordType>({
5858

5959
return (
6060
<table style={{ tableLayout: 'fixed', visibility: columnWidthsReady ? null : 'hidden' }}>
61-
<ColGroup colWidths={[...colWidths, scrollbarSize]} columCount={columCount + 1} />
61+
<ColGroup
62+
colWidths={[...colWidths, scrollbarSize]}
63+
columCount={columCount + 1}
64+
columns={flattenColumnsWithScrollbar}
65+
/>
6266
<Header
6367
{...props}
6468
stickyOffsets={headerStickyOffsets}

tests/FixedHeader.spec.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { mount } from 'enzyme';
33
import { act } from 'react-dom/test-utils';
4-
import Table from '../src';
4+
import Table, { INTERNAL_COL_DEFINE } from '../src';
55

66
describe('Table.FixedHeader', () => {
77
it('switch column', () => {
@@ -64,4 +64,37 @@ describe('Table.FixedHeader', () => {
6464

6565
jest.useRealTimers();
6666
});
67+
68+
it('INTERNAL_COL_DEFINE', () => {
69+
const col1 = {
70+
dataIndex: 'light',
71+
width: 100,
72+
[INTERNAL_COL_DEFINE]: { className: 'test-internal' },
73+
};
74+
const col2 = { dataIndex: 'bamboo', width: 200 };
75+
const wrapper = mount(
76+
<Table
77+
columns={[col1, col2]}
78+
data={[{ light: 'bamboo', bamboo: 'light', key: 1 }]}
79+
scroll={{ y: 10 }}
80+
/>,
81+
);
82+
83+
expect(
84+
wrapper
85+
.find('table')
86+
.last()
87+
.find('colgroup col')
88+
.first()
89+
.props().className,
90+
).toEqual('test-internal');
91+
expect(
92+
wrapper
93+
.find('table')
94+
.first()
95+
.find('colgroup col')
96+
.first()
97+
.props().className,
98+
).toEqual('test-internal');
99+
});
67100
});

0 commit comments

Comments
 (0)