From b68cfea81c893a27a251ebebdc74e6b133192819 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 3 Sep 2025 18:32:19 +0800 Subject: [PATCH 1/4] fix: handle empty or falsy column widths in FixedHolder --- src/ColGroup.tsx | 2 +- src/FixedHolder/index.tsx | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/ColGroup.tsx b/src/ColGroup.tsx index a20e58c28..f5161049c 100644 --- a/src/ColGroup.tsx +++ b/src/ColGroup.tsx @@ -22,7 +22,7 @@ function ColGroup({ colWidths, columns, columCount }: ColGroupProps< for (let i = len - 1; i >= 0; i -= 1) { const width = colWidths[i]; const column = columns && columns[i]; - let additionalProps; + let additionalProps: any; let minWidth: number; if (column) { additionalProps = column[INTERNAL_COL_DEFINE]; diff --git a/src/FixedHolder/index.tsx b/src/FixedHolder/index.tsx index 86e739be1..c48d18323 100644 --- a/src/FixedHolder/index.tsx +++ b/src/FixedHolder/index.tsx @@ -139,7 +139,13 @@ const FixedHolder = React.forwardRef>((pro const colGroupNode = useMemo(() => { // use original ColGroup if no data or no calculated column width, otherwise use calculated column width - if (noData || !mergedColumnWidth) { + // 如果没有数据,或者 mergedColumnWidth 为空,或者 mergedColumnWidth 里全是 falsy 值,则返回原始 colGroup + if ( + noData || + !mergedColumnWidth || + mergedColumnWidth.length === 0 || + mergedColumnWidth.every(width => !width) + ) { return colGroup; } return ( @@ -149,7 +155,14 @@ const FixedHolder = React.forwardRef>((pro columns={flattenColumnsWithScrollbar} /> ); - }, [noData, mergedColumnWidth, colGroup, combinationScrollBarSize, columCount, flattenColumnsWithScrollbar]); + }, [ + noData, + mergedColumnWidth, + colGroup, + combinationScrollBarSize, + columCount, + flattenColumnsWithScrollbar, + ]); return (
Date: Wed, 3 Sep 2025 18:36:35 +0800 Subject: [PATCH 2/4] test: update snapshot --- tests/__snapshots__/Table.spec.jsx.snap | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/tests/__snapshots__/Table.spec.jsx.snap b/tests/__snapshots__/Table.spec.jsx.snap index 8741bf5b8..f3edd6e4d 100644 --- a/tests/__snapshots__/Table.spec.jsx.snap +++ b/tests/__snapshots__/Table.spec.jsx.snap @@ -216,20 +216,7 @@ LoadedCheerio { - - - - - - + Date: Wed, 3 Sep 2025 18:37:27 +0800 Subject: [PATCH 3/4] Update src/FixedHolder/index.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/FixedHolder/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FixedHolder/index.tsx b/src/FixedHolder/index.tsx index c48d18323..09e4598b1 100644 --- a/src/FixedHolder/index.tsx +++ b/src/FixedHolder/index.tsx @@ -139,7 +139,7 @@ const FixedHolder = React.forwardRef>((pro const colGroupNode = useMemo(() => { // use original ColGroup if no data or no calculated column width, otherwise use calculated column width - // 如果没有数据,或者 mergedColumnWidth 为空,或者 mergedColumnWidth 里全是 falsy 值,则返回原始 colGroup + // Return original colGroup if no data, or mergedColumnWidth is empty, or all widths are falsy if ( noData || !mergedColumnWidth || From 5d8f052587eb4794f1d62d7fc243ebe628d12c5b Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 3 Sep 2025 18:37:35 +0800 Subject: [PATCH 4/4] Update src/ColGroup.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/ColGroup.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ColGroup.tsx b/src/ColGroup.tsx index f5161049c..6c49f304f 100644 --- a/src/ColGroup.tsx +++ b/src/ColGroup.tsx @@ -22,7 +22,7 @@ function ColGroup({ colWidths, columns, columCount }: ColGroupProps< for (let i = len - 1; i >= 0; i -= 1) { const width = colWidths[i]; const column = columns && columns[i]; - let additionalProps: any; + let additionalProps: Record; let minWidth: number; if (column) { additionalProps = column[INTERNAL_COL_DEFINE];