From 5871a113f93d60f3f417e32611124d1ad0f79d70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kiner-tang=28=E6=96=87=E8=BE=89=29?= <1127031143@qq.com> Date: Fri, 16 Feb 2024 08:31:34 +0800 Subject: [PATCH 1/8] fix: solve fixed column's shadow display unexpected issue --- docs/demo/shadow.md | 8 ++ docs/examples/shadow.tsx | 187 ++++++++++++++++++++++++++++++++++++++ src/Table.tsx | 2 +- src/hooks/useFixedInfo.ts | 10 +- src/utils/fixUtil.ts | 8 +- 5 files changed, 202 insertions(+), 13 deletions(-) create mode 100644 docs/demo/shadow.md create mode 100644 docs/examples/shadow.tsx diff --git a/docs/demo/shadow.md b/docs/demo/shadow.md new file mode 100644 index 000000000..9f4066352 --- /dev/null +++ b/docs/demo/shadow.md @@ -0,0 +1,8 @@ +--- +title: shadow +nav: + title: Demo + path: /demo +--- + + diff --git a/docs/examples/shadow.tsx b/docs/examples/shadow.tsx new file mode 100644 index 000000000..e72b6fff7 --- /dev/null +++ b/docs/examples/shadow.tsx @@ -0,0 +1,187 @@ +import React from 'react'; +import Table from 'rc-table'; +import '../../assets/index.less'; +import type { ColumnsType } from '@/interface'; + +interface DataType { + key: React.Key; + name: string; + age: number; + street: string; + building: string; + number: number; + companyAddress: string; + companyName: string; + gender: string; +} + +const columns: TableColumnsType = [ + { + title: 'Other', + fixed: 'left', + ellipsis: true, + children: [ + { + title: 'Age', + dataIndex: 'age', + key: 'age', + width: 150, + fixed: 'left', + ellipsis: true, + sorter: (a, b) => a.age - b.age, + }, + { + title: 'Address', + children: [ + { + title: 'Street', + dataIndex: 'street', + key: 'street', + width: 150, + fixed: 'left', + ellipsis: true, + }, + { + title: 'Block', + children: [ + { + title: 'Door No.', + dataIndex: 'number', + key: 'number', + width: 100, + fixed: 'left', + ellipsis: true, + }, + { + title: 'Building', + dataIndex: 'building', + key: 'building', + width: 100, + fixed: 'left', + ellipsis: true, + }, + ], + }, + ], + }, + ], + }, + { + title: 'Name', + dataIndex: 'name', + key: 'name', + width: 100, + filters: [ + { + text: 'Joe', + value: 'Joe', + }, + { + text: 'John', + value: 'John', + }, + ], + onFilter: (value: string, record) => record.name.indexOf(value) === 0, + }, + { + title: 'Company', + children: [ + { + title: 'Company Address', + dataIndex: 'companyAddress', + key: 'companyAddress', + width: 200, + }, + { + title: 'Company Name', + dataIndex: 'companyName', + key: 'companyName', + }, + ], + }, + { + title: 'Gender', + dataIndex: 'gender', + key: 'gender', + width: 80, + fixed: 'right', + }, +]; + +const data: DataType[] = []; +for (let i = 0; i < 100; i++) { + data.push({ + key: i, + name: 'John Brown', + age: i + 1, + street: 'Lake Park', + building: 'C', + number: 2035, + companyAddress: 'Lake Street 42', + companyName: 'SoftLake Co', + gender: 'M', + }); +} + +interface User { + key: number; + name: string; +} + +const columns2: ColumnsType = [ + { + title: '父表头右侧的阴影导致整个表格最右侧有空隙', + key: 'title', + children: [ + { + key: 'name0', + title: 'Name0', + fixed: 'left', + dataIndex: 'name0', + }, + { + key: 'name1', + title: 'Name1', + fixed: 'left', + dataIndex: 'name1', + }, + { + key: 'name2', + title: 'Name2', + dataIndex: 'name2', + }, + { + key: 'name3', + title: 'Name3', + fixed: 'right', + dataIndex: 'name3', + }, + ], + }, +]; + +const data2: User[] = [ + { + key: 0, + name: 'Jack', + }, + { + key: 1, + name: 'Jack1', + }, + { + key: 2, + name: 'Jack1', + }, +]; + +const Demo = () => ( +
+

colSpan & rowSpan

+ +
+
+ +); + +export default Demo; diff --git a/src/Table.tsx b/src/Table.tsx index 76b36818d..1bd9d323d 100644 --- a/src/Table.tsx +++ b/src/Table.tsx @@ -773,7 +773,7 @@ function Table( fullTable = {fullTable}; } - const fixedInfoList = useFixedInfo(flattenColumns, stickyOffsets, direction, columns); + const fixedInfoList = useFixedInfo(flattenColumns, stickyOffsets, direction); const TableContextValue = React.useMemo( () => ({ diff --git a/src/hooks/useFixedInfo.ts b/src/hooks/useFixedInfo.ts index bafef0981..56409cde6 100644 --- a/src/hooks/useFixedInfo.ts +++ b/src/hooks/useFixedInfo.ts @@ -7,17 +7,9 @@ export default function useFixedInfo( flattenColumns: readonly ColumnType[], stickyOffsets: StickyOffsets, direction: Direction, - columns: ColumnsType, ) { const fixedInfoList = flattenColumns.map((_, colIndex) => - getCellFixedInfo( - colIndex, - colIndex, - flattenColumns, - stickyOffsets, - direction, - columns?.[colIndex], - ), + getCellFixedInfo(colIndex, colIndex, flattenColumns, stickyOffsets, direction), ); return useMemo( diff --git a/src/utils/fixUtil.ts b/src/utils/fixUtil.ts index 4e4431de8..36161286f 100644 --- a/src/utils/fixUtil.ts +++ b/src/utils/fixUtil.ts @@ -25,7 +25,6 @@ export function getCellFixedInfo( columns: readonly { fixed?: FixedType }[], stickyOffsets: StickyOffsets, direction: Direction, - curColumns?: ColumnType | ColumnGroupType, ): FixedInfo { const startColumn = columns[colStart] || {}; const endColumn = columns[colEnd] || {}; @@ -48,8 +47,11 @@ export function getCellFixedInfo( const nextColumn = columns[colEnd + 1]; const prevColumn = columns[colStart - 1]; - // no children only - const canLastFix = !(curColumns as ColumnGroupType)?.children; + // need show shadow only when canLastFix is true + const canLastFix = + (nextColumn && nextColumn.fixed === undefined) || + (prevColumn && prevColumn.fixed === undefined) || + columns.every(col => col.fixed === 'left'); if (direction === 'rtl') { if (fixLeft !== undefined) { From c368c6f9357d0edf30bef03f5dfe62b688d72027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kiner-tang=28=E6=96=87=E8=BE=89=29?= <1127031143@qq.com> Date: Fri, 16 Feb 2024 08:38:02 +0800 Subject: [PATCH 2/8] fix: solve fixed column's shadow display unexpected issue --- src/utils/fixUtil.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/utils/fixUtil.ts b/src/utils/fixUtil.ts index 36161286f..6adf23eed 100644 --- a/src/utils/fixUtil.ts +++ b/src/utils/fixUtil.ts @@ -1,10 +1,4 @@ -import type { - ColumnGroupType, - ColumnType, - Direction, - FixedType, - StickyOffsets, -} from '../interface'; +import type { Direction, FixedType, StickyOffsets } from '../interface'; export interface FixedInfo { fixLeft: number | false; From f9cd6dadea3957402002811d37276efd75bc6980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kiner-tang=28=E6=96=87=E8=BE=89=29?= <1127031143@qq.com> Date: Fri, 16 Feb 2024 08:52:10 +0800 Subject: [PATCH 3/8] fix: solve fixed column's shadow display unexpected issue --- src/Footer/Cell.tsx | 4 ++-- src/Header/HeaderRow.tsx | 3 +-- src/hooks/useFixedInfo.ts | 2 +- src/utils/fixUtil.ts | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Footer/Cell.tsx b/src/Footer/Cell.tsx index c36ca9a9f..119071a58 100644 --- a/src/Footer/Cell.tsx +++ b/src/Footer/Cell.tsx @@ -24,7 +24,8 @@ export default function SummaryCell({ align, }: SummaryCellProps) { const { prefixCls, direction } = useContext(TableContext, ['prefixCls', 'direction']); - const { scrollColumnIndex, stickyOffsets, flattenColumns, columns } = React.useContext(SummaryContext); + const { scrollColumnIndex, stickyOffsets, flattenColumns, columns } = + React.useContext(SummaryContext); const lastIndex = index + colSpan - 1; const mergedColSpan = lastIndex + 1 === scrollColumnIndex ? colSpan + 1 : colSpan; @@ -34,7 +35,6 @@ export default function SummaryCell({ flattenColumns, stickyOffsets, direction, - columns?.[index] ); return ( diff --git a/src/Header/HeaderRow.tsx b/src/Header/HeaderRow.tsx index 864dc0bc5..eafc64e21 100644 --- a/src/Header/HeaderRow.tsx +++ b/src/Header/HeaderRow.tsx @@ -48,13 +48,12 @@ function HeaderRow({ {cells.map((cell: CellType, cellIndex) => { const { column } = cell; - const fixedInfo = getCellFixedInfo( + const fixedInfo = getCellFixedInfo( cell.colStart, cell.colEnd, flattenColumns, stickyOffsets, direction, - column, ); let additionalProps: React.HTMLAttributes; diff --git a/src/hooks/useFixedInfo.ts b/src/hooks/useFixedInfo.ts index 56409cde6..d2ea2e687 100644 --- a/src/hooks/useFixedInfo.ts +++ b/src/hooks/useFixedInfo.ts @@ -1,6 +1,6 @@ import useMemo from 'rc-util/lib/hooks/useMemo'; import isEqual from 'rc-util/lib/isEqual'; -import type { ColumnsType, ColumnType, Direction, StickyOffsets } from '../interface'; +import type { ColumnType, Direction, StickyOffsets } from '../interface'; import { getCellFixedInfo } from '../utils/fixUtil'; export default function useFixedInfo( diff --git a/src/utils/fixUtil.ts b/src/utils/fixUtil.ts index 6adf23eed..6c29f9eea 100644 --- a/src/utils/fixUtil.ts +++ b/src/utils/fixUtil.ts @@ -13,7 +13,7 @@ export interface FixedInfo { isSticky: boolean; } -export function getCellFixedInfo( +export function getCellFixedInfo( colStart: number, colEnd: number, columns: readonly { fixed?: FixedType }[], From 53d664eb5ec550096af696477a88f6452cd5cc27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kiner-tang=28=E6=96=87=E8=BE=89=29?= <1127031143@qq.com> Date: Fri, 16 Feb 2024 08:57:24 +0800 Subject: [PATCH 4/8] fix: solve fixed column's shadow display unexpected issue --- src/Footer/Cell.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Footer/Cell.tsx b/src/Footer/Cell.tsx index 119071a58..2ecbd407a 100644 --- a/src/Footer/Cell.tsx +++ b/src/Footer/Cell.tsx @@ -24,8 +24,7 @@ export default function SummaryCell({ align, }: SummaryCellProps) { const { prefixCls, direction } = useContext(TableContext, ['prefixCls', 'direction']); - const { scrollColumnIndex, stickyOffsets, flattenColumns, columns } = - React.useContext(SummaryContext); + const { scrollColumnIndex, stickyOffsets, flattenColumns } = React.useContext(SummaryContext); const lastIndex = index + colSpan - 1; const mergedColSpan = lastIndex + 1 === scrollColumnIndex ? colSpan + 1 : colSpan; From 17bed24efe4d97872282b6e2bb32b8f3095552ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kiner-tang=28=E6=96=87=E8=BE=89=29?= <1127031143@qq.com> Date: Fri, 16 Feb 2024 15:28:14 +0800 Subject: [PATCH 5/8] fix: solve fixed column's shadow display unexpected issue --- vitest.config.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vitest.config.ts b/vitest.config.ts index a61325b92..1702045a7 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -9,5 +9,8 @@ export default defineConfig({ globals: true, setupFiles: './tests/setup.ts', environment: 'jsdom', + coverage: { + exclude: ['**/docs/**', '**/__mocks__/**'], + }, }, }); From b34469b3481a8318e414ffc04576b131f62ff20a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kiner-tang=28=E6=96=87=E8=BE=89=29?= <1127031143@qq.com> Date: Sat, 17 Feb 2024 15:43:58 +0800 Subject: [PATCH 6/8] feat: add test case --- docs/examples/shadow.tsx | 4 + tests/FixedColumn.spec.tsx | 11 + tests/__mocks__/shadowTest.tsx | 180 + tests/__snapshots__/FixedColumn.spec.tsx.snap | 6258 +++++++++++++++++ tsconfig.json | 2 +- vitest.config.ts | 1 + 6 files changed, 6455 insertions(+), 1 deletion(-) create mode 100644 tests/__mocks__/shadowTest.tsx diff --git a/docs/examples/shadow.tsx b/docs/examples/shadow.tsx index e72b6fff7..e87fac617 100644 --- a/docs/examples/shadow.tsx +++ b/docs/examples/shadow.tsx @@ -138,23 +138,27 @@ const columns2: ColumnsType = [ title: 'Name0', fixed: 'left', dataIndex: 'name0', + width: 100, }, { key: 'name1', title: 'Name1', fixed: 'left', dataIndex: 'name1', + width: 100, }, { key: 'name2', title: 'Name2', dataIndex: 'name2', + width: 500, }, { key: 'name3', title: 'Name3', fixed: 'right', dataIndex: 'name3', + width: 100, }, ], }, diff --git a/tests/FixedColumn.spec.tsx b/tests/FixedColumn.spec.tsx index d4168af12..628073aa5 100644 --- a/tests/FixedColumn.spec.tsx +++ b/tests/FixedColumn.spec.tsx @@ -6,6 +6,7 @@ import { spyElementPrototypes } from 'rc-util/lib/test/domHook'; import { act } from 'react-dom/test-utils'; import Table, { type ColumnsType } from '../src'; import { safeAct } from './utils'; +import { RowColSpanWithFixed, RowColSpanWithFixed2 } from './__mocks__/shadowTest'; function triggerResize(ele: HTMLElement) { _rs([{ target: ele }] as any); @@ -298,4 +299,14 @@ describe('Table.FixedColumn', () => { expect(container.querySelector('.healer-table')).toBeTruthy(); }); }); + it('shadow should display correctly', async () => { + const { container, rerender } = render(); + expect(container.querySelectorAll('.rc-table-cell-fix-left-last').length).toBe(104); + expect(container.querySelectorAll('.rc-table-cell-fix-right-first').length).toBe(101); + expect(container).toMatchSnapshot(); + rerender(); + expect(container.querySelectorAll('.rc-table-cell-fix-left-last').length).toBe(4); + expect(container.querySelectorAll('.rc-table-cell-fix-right-first').length).toBe(4); + expect(container).toMatchSnapshot(); + }); }); diff --git a/tests/__mocks__/shadowTest.tsx b/tests/__mocks__/shadowTest.tsx new file mode 100644 index 000000000..42ed6debf --- /dev/null +++ b/tests/__mocks__/shadowTest.tsx @@ -0,0 +1,180 @@ +import React from 'react'; +import Table from '../../src'; +import '../../assets/index.less'; +import type { ColumnsType } from '../../src'; + +interface DataType { + key: React.Key; + name: string; + age: number; + street: string; + building: string; + number: number; + companyAddress: string; + companyName: string; + gender: string; +} + +const columns: ColumnsType = [ + { + title: 'Other', + fixed: 'left', + ellipsis: true, + children: [ + { + title: 'Age', + dataIndex: 'age', + key: 'age', + width: 150, + fixed: 'left', + ellipsis: true, + }, + { + title: 'Address', + children: [ + { + title: 'Street', + dataIndex: 'street', + key: 'street', + width: 150, + fixed: 'left', + ellipsis: true, + }, + { + title: 'Block', + children: [ + { + title: 'Door No.', + dataIndex: 'number', + key: 'number', + width: 100, + fixed: 'left', + ellipsis: true, + }, + { + title: 'Building', + dataIndex: 'building', + key: 'building', + width: 100, + fixed: 'left', + ellipsis: true, + }, + ], + }, + ], + }, + ], + }, + { + title: 'Name', + dataIndex: 'name', + key: 'name', + width: 100, + }, + { + title: 'Company', + children: [ + { + title: 'Company Address', + dataIndex: 'companyAddress', + key: 'companyAddress', + width: 200, + }, + { + title: 'Company Name', + dataIndex: 'companyName', + key: 'companyName', + }, + ], + }, + { + title: 'Gender', + dataIndex: 'gender', + key: 'gender', + width: 80, + fixed: 'right', + }, +]; + +const data: DataType[] = []; +for (let i = 0; i < 100; i++) { + data.push({ + key: i, + name: 'John Brown', + age: i + 1, + street: 'Lake Park', + building: 'C', + number: 2035, + companyAddress: 'Lake Street 42', + companyName: 'SoftLake Co', + gender: 'M', + }); +} + +interface User { + key: number; + name: string; +} + +const columns2: ColumnsType = [ + { + title: '父表头右侧的阴影导致整个表格最右侧有空隙', + key: 'title', + children: [ + { + key: 'name0', + title: 'Name0', + fixed: 'left', + dataIndex: 'name0', + width: 100, + }, + { + key: 'name1', + title: 'Name1', + fixed: 'left', + dataIndex: 'name1', + width: 100, + }, + { + key: 'name2', + title: 'Name2', + dataIndex: 'name2', + width: 500, + }, + { + key: 'name3', + title: 'Name3', + fixed: 'right', + dataIndex: 'name3', + width: 100, + }, + ], + }, +]; + +const data2: User[] = [ + { + key: 0, + name: 'Jack', + }, + { + key: 1, + name: 'Jack1', + }, + { + key: 2, + name: 'Jack1', + }, +]; + +export const RowColSpanWithFixed = () => ( +
+); +export const RowColSpanWithFixed2 = () => ( +
+); + +export default { + RowColSpanWithFixed, + RowColSpanWithFixed2, +}; diff --git a/tests/__snapshots__/FixedColumn.spec.tsx.snap b/tests/__snapshots__/FixedColumn.spec.tsx.snap index 273f7f0c2..559ffb5eb 100644 --- a/tests/__snapshots__/FixedColumn.spec.tsx.snap +++ b/tests/__snapshots__/FixedColumn.spec.tsx.snap @@ -3143,3 +3143,6261 @@ LoadedCheerio { }, } `; + +exports[`Table.FixedColumn > shadow should display correctly 1`] = ` +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + Other + + + Name + + Company + + Gender + +
+ Age + + Address + + Company Address + + Company Name +
+ Street + + Block +
+ Door No. + + + Building + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 1 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 2 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 3 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 4 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 5 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 6 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 7 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 8 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 9 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 10 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 11 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 12 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 13 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 14 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 15 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 16 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 17 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 18 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 19 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 20 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 21 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 22 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 23 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 24 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 25 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 26 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 27 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 28 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 29 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 30 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 31 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 32 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 33 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 34 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 35 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 36 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 37 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 38 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 39 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 40 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 41 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 42 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 43 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 44 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 45 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 46 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 47 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 48 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 49 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 50 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 51 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 52 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 53 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 54 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 55 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 56 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 57 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 58 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 59 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 60 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 61 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 62 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 63 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 64 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 65 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 66 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 67 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 68 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 69 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 70 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 71 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 72 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 73 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 74 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 75 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 76 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 77 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 78 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 79 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 80 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 81 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 82 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 83 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 84 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 85 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 86 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 87 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 88 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 89 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 90 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 91 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 92 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 93 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 94 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 95 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 96 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 97 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 98 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 99 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+ 100 + + Lake Park + + 2035 + + + C + + + John Brown + + Lake Street 42 + + SoftLake Co + + M +
+
+ + + +`; + +exports[`Table.FixedColumn > shadow should display correctly 2`] = ` +
+
+
+
+ + + + + + + + + + + + + +
+ 父表头右侧的阴影导致整个表格最右侧有空隙 + +
+ Name0 + + Name1 + + Name2 + + Name3 +
+
+
+ + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + +
+
+
+
+
+`; diff --git a/tsconfig.json b/tsconfig.json index b7bdcf0fb..b9e1a1145 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,5 +14,5 @@ }, "types": ["vitest/globals", "@testing-library/jest-dom"] }, - "include": [".dumirc.ts", "**/*.ts", "**/*.tsx"] + "include": [".dumirc.ts", "**/*.ts", "**/*.tsx", "tests/__mocks__/shadowTest.tsx"] } diff --git a/vitest.config.ts b/vitest.config.ts index 1702045a7..9e20d8717 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -6,6 +6,7 @@ export default defineConfig({ }, test: { include: ['**/tests/*.spec.*'], + exclude: ['**/coverage/**'], globals: true, setupFiles: './tests/setup.ts', environment: 'jsdom', From 8ed1db86f166335cedcd0c6e8d6c5b3acbdc3429 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kiner-tang=28=E6=96=87=E8=BE=89=29?= <1127031143@qq.com> Date: Sun, 18 Feb 2024 11:00:40 +0800 Subject: [PATCH 7/8] feat: optimize code --- src/Footer/SummaryContext.tsx | 3 +-- src/Footer/index.tsx | 8 +++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Footer/SummaryContext.tsx b/src/Footer/SummaryContext.tsx index 04fc13cda..5e57c9200 100644 --- a/src/Footer/SummaryContext.tsx +++ b/src/Footer/SummaryContext.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import type { ColumnsType, ColumnType, StickyOffsets } from '../interface'; +import type { ColumnType, StickyOffsets } from '../interface'; type FlattenColumns = readonly (ColumnType & { scrollbar?: boolean })[]; @@ -7,7 +7,6 @@ const SummaryContext = React.createContext<{ stickyOffsets?: StickyOffsets; scrollColumnIndex?: number; flattenColumns?: FlattenColumns; - columns?: ColumnsType; }>({}); export default SummaryContext; diff --git a/src/Footer/index.tsx b/src/Footer/index.tsx index c2e5986a7..edd9506ef 100644 --- a/src/Footer/index.tsx +++ b/src/Footer/index.tsx @@ -2,7 +2,7 @@ import { useContext } from '@rc-component/context'; import * as React from 'react'; import TableContext, { responseImmutable } from '../context/TableContext'; import devRenderTimes from '../hooks/useRenderTimes'; -import type { ColumnsType, ColumnType, StickyOffsets } from '../interface'; +import type { ColumnType, StickyOffsets } from '../interface'; import Summary from './Summary'; import SummaryContext from './SummaryContext'; @@ -12,7 +12,6 @@ export interface FooterProps { children: React.ReactNode; stickyOffsets: StickyOffsets; flattenColumns: FlattenColumns; - columns: ColumnsType; } function Footer(props: FooterProps) { @@ -20,7 +19,7 @@ function Footer(props: FooterProps) { devRenderTimes(props); } - const { children, stickyOffsets, flattenColumns, columns } = props; + const { children, stickyOffsets, flattenColumns } = props; const prefixCls = useContext(TableContext, 'prefixCls'); @@ -32,9 +31,8 @@ function Footer(props: FooterProps) { stickyOffsets, flattenColumns, scrollColumnIndex: scrollColumn?.scrollbar ? lastColumnIndex : null, - columns, }), - [scrollColumn, flattenColumns, lastColumnIndex, stickyOffsets, columns], + [scrollColumn, flattenColumns, lastColumnIndex, stickyOffsets], ); return ( From 909ae2da9dafdde00c239c4530d87b7919f1771f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kiner-tang=28=E6=96=87=E8=BE=89=29?= <1127031143@qq.com> Date: Sun, 18 Feb 2024 11:05:58 +0800 Subject: [PATCH 8/8] feat: optimize code --- src/Table.tsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Table.tsx b/src/Table.tsx index fa231af0b..ffb7f94f6 100644 --- a/src/Table.tsx +++ b/src/Table.tsx @@ -646,11 +646,7 @@ function Table( {bodyColGroup} {bodyTable} {!fixFooter && summaryNode && ( -