Skip to content

Commit 9e2d095

Browse files
committed
chore: clean up
1 parent 867ffe5 commit 9e2d095

File tree

3 files changed

+8
-46
lines changed

3 files changed

+8
-46
lines changed

src/Cell/index.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,12 @@ function Cell<RecordType>(props: CellProps<RecordType>) {
116116
} = props;
117117

118118
const cellPrefixCls = `${prefixCls}-cell`;
119-
const { allColumnsFixedLeft, rowHoverable } = useContext(TableContext, [
120-
'allColumnsFixedLeft',
119+
const {
120+
// zombieJ: not used anymore?
121+
// allColumnsFixedLeft,
122+
rowHoverable,
123+
} = useContext(TableContext, [
124+
// 'allColumnsFixedLeft',
121125
'rowHoverable',
122126
]);
123127

@@ -199,12 +203,8 @@ function Cell<RecordType>(props: CellProps<RecordType>) {
199203
// Fixed
200204
[`${cellPrefixCls}-fix`]: isFixStart || isFixEnd,
201205
[`${cellPrefixCls}-fix-start`]: isFixStart,
202-
// [`${cellPrefixCls}-fix-left-first`]: firstFixLeft && supportSticky,
203-
// [`${cellPrefixCls}-fix-left-last`]: lastFixLeft && supportSticky,
204206
// [`${cellPrefixCls}-fix-left-all`]: lastFixLeft && allColumnsFixedLeft && supportSticky,
205207
[`${cellPrefixCls}-fix-end`]: isFixEnd,
206-
// [`${cellPrefixCls}-fix-right-first`]: firstFixRight && supportSticky,
207-
// [`${cellPrefixCls}-fix-right-last`]: lastFixRight && supportSticky,
208208

209209
// Fixed shadow
210210
[`${cellPrefixCls}-fix-start-shadow`]: fixedStartShadow,

src/Table.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ function Table<RecordType extends DefaultRecordType>(
290290
const scrollX = scroll?.x;
291291
const [componentWidth, setComponentWidth] = React.useState(0);
292292

293-
const [columns, flattenColumns, flattenScrollX, hasGapFixed] = useColumns(
293+
const [columns, flattenColumns, flattenScrollX] = useColumns(
294294
{
295295
...props,
296296
...expandableConfig,
@@ -777,7 +777,6 @@ function Table<RecordType extends DefaultRecordType>(
777777
[`${prefixCls}-fixed-header`]: fixHeader,
778778
/** No used but for compatible */
779779
[`${prefixCls}-fixed-column`]: fixColumn,
780-
[`${prefixCls}-fixed-column-gapped`]: fixColumn && hasGapFixed,
781780
[`${prefixCls}-scroll-horizontal`]: horizonScroll,
782781
[`${prefixCls}-has-fix-left`]: flattenColumns[0] && flattenColumns[0].fixed,
783782
[`${prefixCls}-has-fix-right`]:

src/hooks/useColumns/index.tsx

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ function useColumns<RecordType>(
152152
columns: ColumnsType<RecordType>,
153153
flattenColumns: readonly ColumnType<RecordType>[],
154154
realScrollWidth: undefined | number,
155-
hasGapFixed: boolean,
156155
] {
157156
const baseColumns = React.useMemo<ColumnsType<RecordType>>(() => {
158157
const newColumns = columns || convertChildrenToColumns(children) || [];
@@ -275,50 +274,14 @@ function useColumns<RecordType>(
275274
// eslint-disable-next-line react-hooks/exhaustive-deps
276275
}, [mergedColumns, direction, scrollWidth]);
277276

278-
// ========================= Gap Fixed ========================
279-
// TODO: Remove this. We no need gapped check anymore
280-
const hasGapFixed = React.useMemo(() => {
281-
// Fixed: left, since old browser not support `findLastIndex`, we should use reverse loop
282-
let lastLeftIndex = -1;
283-
for (let i = flattenColumns.length - 1; i >= 0; i -= 1) {
284-
const colFixed = flattenColumns[i].fixed;
285-
if (colFixed === 'left' || colFixed === true) {
286-
lastLeftIndex = i;
287-
break;
288-
}
289-
}
290-
291-
if (lastLeftIndex >= 0) {
292-
for (let i = 0; i <= lastLeftIndex; i += 1) {
293-
const colFixed = flattenColumns[i].fixed;
294-
if (colFixed !== 'left' && colFixed !== true) {
295-
return true;
296-
}
297-
}
298-
}
299-
300-
// Fixed: right
301-
const firstRightIndex = flattenColumns.findIndex(({ fixed: colFixed }) => colFixed === 'right');
302-
if (firstRightIndex >= 0) {
303-
for (let i = firstRightIndex; i < flattenColumns.length; i += 1) {
304-
const colFixed = flattenColumns[i].fixed;
305-
if (colFixed !== 'right') {
306-
return true;
307-
}
308-
}
309-
}
310-
311-
return false;
312-
}, [flattenColumns]);
313-
314277
// ========================= FillWidth ========================
315278
const [filledColumns, realScrollWidth] = useWidthColumns(
316279
flattenColumns,
317280
scrollWidth,
318281
clientWidth,
319282
);
320283

321-
return [mergedColumns, filledColumns, realScrollWidth, hasGapFixed];
284+
return [mergedColumns, filledColumns, realScrollWidth];
322285
}
323286

324287
export default useColumns;

0 commit comments

Comments
 (0)