Skip to content

Commit ab53462

Browse files
committed
chore: add zIndex placeholder
1 parent 76dad74 commit ab53462

3 files changed

Lines changed: 18 additions & 7 deletions

File tree

src/Footer/Cell.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,9 @@ export default function SummaryCell({
2828
const lastIndex = index + colSpan - 1;
2929
const mergedColSpan = lastIndex + 1 === scrollColumnIndex ? colSpan + 1 : colSpan;
3030

31-
const fixedInfo = getCellFixedInfo(
32-
index,
33-
index + mergedColSpan - 1,
34-
flattenColumns,
35-
stickyOffsets,
31+
const fixedInfo = React.useMemo(
32+
() => getCellFixedInfo(index, index + mergedColSpan - 1, flattenColumns, stickyOffsets),
33+
[index, mergedColSpan, flattenColumns, stickyOffsets],
3634
);
3735

3836
return (

src/hooks/useFixedInfo.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@ import useMemo from '@rc-component/util/lib/hooks/useMemo';
22
import isEqual from '@rc-component/util/lib/isEqual';
33
import type { ColumnType, StickyOffsets } from '../interface';
44
import { getCellFixedInfo } from '../utils/fixUtil';
5+
import * as React from 'react';
56

67
export default function useFixedInfo<RecordType>(
78
flattenColumns: readonly ColumnType<RecordType>[],
89
stickyOffsets: StickyOffsets,
910
) {
10-
const fixedInfoList = flattenColumns.map((_, colIndex) =>
11-
getCellFixedInfo(colIndex, colIndex, flattenColumns, stickyOffsets),
11+
const fixedInfoList = React.useMemo(
12+
() =>
13+
flattenColumns.map((_, colIndex) =>
14+
getCellFixedInfo(colIndex, colIndex, flattenColumns, stickyOffsets),
15+
),
16+
[flattenColumns, stickyOffsets],
1217
);
1318

1419
return useMemo(

src/utils/fixUtil.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export interface FixedInfo {
1111
fixedStartShadow?: boolean;
1212
/** `fixed: end` with shadow */
1313
fixedEndShadow?: boolean;
14+
1415
zIndex?: number;
1516
}
1617

@@ -39,12 +40,19 @@ export function getCellFixedInfo(
3940
fixEnd = stickyOffsets.end[colEnd];
4041
}
4142

43+
console.log('fixStart:', colStart);
44+
4245
// check if need to add shadow
4346
const fixedStartShadow =
4447
fixStart !== null && (!columns[colStart + 1] || !isFixedStart(columns[colStart + 1]));
4548
const fixedEndShadow =
4649
fixEnd !== null && (!columns[colEnd - 1] || !isFixedEnd(columns[colEnd - 1]));
4750

51+
// Calc `zIndex`.
52+
// first fixed start (start -> end) column `zIndex` should be greater than next column.
53+
// first fixed end (end -> start) column `zIndex` should be greater than next column.
54+
// TODO: handle this
55+
4856
return {
4957
fixStart,
5058
fixEnd,

0 commit comments

Comments
 (0)