Skip to content

Commit

Permalink
fix: shadow should be shown when there are columns where fixed is fal…
Browse files Browse the repository at this point in the history
…se (#1113)
  • Loading branch information
linxianxi committed Apr 30, 2024
1 parent b43c2f2 commit fb65b78
Show file tree
Hide file tree
Showing 4 changed files with 2,452 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/utils/fixUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export function getCellFixedInfo(

// need show shadow only when canLastFix is true
const canLastFix =
(nextColumn && nextColumn.fixed === undefined) ||
(prevColumn && prevColumn.fixed === undefined) ||
(nextColumn && !nextColumn.fixed) ||
(prevColumn && !prevColumn.fixed) ||
columns.every(col => col.fixed === 'left');

if (direction === 'rtl') {
Expand Down
32 changes: 32 additions & 0 deletions tests/FixedColumn.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,36 @@ describe('Table.FixedColumn', () => {
expect(container.querySelectorAll('.rc-table-cell-fix-right-first').length).toBe(4);
expect(container).toMatchSnapshot();
});

it('shadow should be shown when there are columns where fixed is false', async () => {
const { container } = render(
<RowColSpanWithFixed
columns={[
{
title: 'Other',
fixed: 'left',
},
{
title: 'Name',
dataIndex: 'name',
key: 'name',
fixed: false,
},
{
title: 'Company',
fixed: false,
},
{
title: 'Gender',
dataIndex: 'gender',
key: 'gender',
fixed: 'right',
},
]}
/>,
);
expect(container.querySelectorAll('.rc-table-cell-fix-left-last').length).toBe(101);
expect(container.querySelectorAll('.rc-table-cell-fix-right-first').length).toBe(101);
expect(container).toMatchSnapshot();
});
});
6 changes: 3 additions & 3 deletions tests/__mocks__/shadowTest.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import Table from '../../src';
import '../../assets/index.less';
import type { ColumnsType } from '../../src';
import type { ColumnsType, TableProps } from '../../src';

interface DataType {
key: React.Key;
Expand Down Expand Up @@ -171,8 +171,8 @@ const data2: User[] = [
},
];

export const RowColSpanWithFixed = () => (
<Table columns={columns} data={data} className="table1" scroll={{ x: 1500, y: 500 }} />
export const RowColSpanWithFixed = (props?: TableProps) => (
<Table columns={columns} data={data} className="table1" scroll={{ x: 1500, y: 500 }} {...props} />
);
export const RowColSpanWithFixed2 = () => (
<Table columns={columns2} data={data2} className="table2" scroll={{ x: 1500, y: 500 }} />
Expand Down

0 comments on commit fb65b78

Please sign in to comment.