Skip to content

Commit fb65b78

Browse files
authored
fix: shadow should be shown when there are columns where fixed is false (#1113)
1 parent b43c2f2 commit fb65b78

File tree

4 files changed

+2452
-5
lines changed

4 files changed

+2452
-5
lines changed

src/utils/fixUtil.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ export function getCellFixedInfo(
4343

4444
// need show shadow only when canLastFix is true
4545
const canLastFix =
46-
(nextColumn && nextColumn.fixed === undefined) ||
47-
(prevColumn && prevColumn.fixed === undefined) ||
46+
(nextColumn && !nextColumn.fixed) ||
47+
(prevColumn && !prevColumn.fixed) ||
4848
columns.every(col => col.fixed === 'left');
4949

5050
if (direction === 'rtl') {

tests/FixedColumn.spec.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,4 +309,36 @@ describe('Table.FixedColumn', () => {
309309
expect(container.querySelectorAll('.rc-table-cell-fix-right-first').length).toBe(4);
310310
expect(container).toMatchSnapshot();
311311
});
312+
313+
it('shadow should be shown when there are columns where fixed is false', async () => {
314+
const { container } = render(
315+
<RowColSpanWithFixed
316+
columns={[
317+
{
318+
title: 'Other',
319+
fixed: 'left',
320+
},
321+
{
322+
title: 'Name',
323+
dataIndex: 'name',
324+
key: 'name',
325+
fixed: false,
326+
},
327+
{
328+
title: 'Company',
329+
fixed: false,
330+
},
331+
{
332+
title: 'Gender',
333+
dataIndex: 'gender',
334+
key: 'gender',
335+
fixed: 'right',
336+
},
337+
]}
338+
/>,
339+
);
340+
expect(container.querySelectorAll('.rc-table-cell-fix-left-last').length).toBe(101);
341+
expect(container.querySelectorAll('.rc-table-cell-fix-right-first').length).toBe(101);
342+
expect(container).toMatchSnapshot();
343+
});
312344
});

tests/__mocks__/shadowTest.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import Table from '../../src';
33
import '../../assets/index.less';
4-
import type { ColumnsType } from '../../src';
4+
import type { ColumnsType, TableProps } from '../../src';
55

66
interface DataType {
77
key: React.Key;
@@ -171,8 +171,8 @@ const data2: User[] = [
171171
},
172172
];
173173

174-
export const RowColSpanWithFixed = () => (
175-
<Table columns={columns} data={data} className="table1" scroll={{ x: 1500, y: 500 }} />
174+
export const RowColSpanWithFixed = (props?: TableProps) => (
175+
<Table columns={columns} data={data} className="table1" scroll={{ x: 1500, y: 500 }} {...props} />
176176
);
177177
export const RowColSpanWithFixed2 = () => (
178178
<Table columns={columns2} data={data2} className="table2" scroll={{ x: 1500, y: 500 }} />

0 commit comments

Comments
 (0)