From d251c19676f07cd512cd41992534012ea9fd2b14 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 22 Sep 2025 17:31:40 +0800 Subject: [PATCH 1/2] refactor: use css instead of inner style in MeasureRow --- assets/index.less | 14 ++++++++++++++ src/Body/MeasureCell.tsx | 19 ++++++++++--------- src/Body/MeasureRow.tsx | 3 ++- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/assets/index.less b/assets/index.less index ef38409d3..72d52ac91 100644 --- a/assets/index.less +++ b/assets/index.less @@ -219,6 +219,20 @@ } } + th&-measure-cell { + padding-top: 0; + padding-bottom: 0; + border-top: 0; + border-bottom: 0; + } + + &-measure-cell-content { + height: 0; + overflow: hidden; + visibility: hidden; + pointer-events: none; + } + &-content { .tableBorder(); border-radius: 5px 0 0 0; diff --git a/src/Body/MeasureCell.tsx b/src/Body/MeasureCell.tsx index 81865c1f1..1db7d06bb 100644 --- a/src/Body/MeasureCell.tsx +++ b/src/Body/MeasureCell.tsx @@ -7,9 +7,15 @@ export interface MeasureCellProps { columnKey: React.Key; onColumnResize: (key: React.Key, width: number) => void; column?: ColumnType; + prefixCls: string; } -export default function MeasureCell({ columnKey, onColumnResize, column }: MeasureCellProps) { +export default function MeasureCell({ + columnKey, + onColumnResize, + column, + prefixCls, +}: MeasureCellProps) { const cellRef = React.useRef(); useLayoutEffect(() => { @@ -20,14 +26,9 @@ export default function MeasureCell({ columnKey, onColumnResize, column }: Measu return ( - -
- {column?.title || '\xa0'} -
- + +
{column?.title || '\xa0'}
+
); } diff --git a/src/Body/MeasureRow.tsx b/src/Body/MeasureRow.tsx index b2541dbdb..14ecb2f8e 100644 --- a/src/Body/MeasureRow.tsx +++ b/src/Body/MeasureRow.tsx @@ -23,7 +23,7 @@ export default function MeasureRow({ const { measureRowRender } = useContext(TableContext, ['measureRowRender']); const measureRow = ( - + { if (isVisible(ref.current)) { @@ -37,6 +37,7 @@ export default function MeasureRow({ const column = columns.find(col => col.key === columnKey); return ( Date: Mon, 22 Sep 2025 17:32:28 +0800 Subject: [PATCH 2/2] fix: update table measure row from td to th and adjust styles --- tests/FixedColumn.spec.tsx | 4 +- tests/__snapshots__/ExpandRow.spec.jsx.snap | 170 ++--- tests/__snapshots__/FixedColumn.spec.tsx.snap | 624 +++++++++--------- tests/__snapshots__/Table.spec.jsx.snap | 26 +- 4 files changed, 412 insertions(+), 412 deletions(-) diff --git a/tests/FixedColumn.spec.tsx b/tests/FixedColumn.spec.tsx index 50a21baf9..5dbe1725d 100644 --- a/tests/FixedColumn.spec.tsx +++ b/tests/FixedColumn.spec.tsx @@ -240,11 +240,11 @@ describe('Table.FixedColumn', () => { it('not break measure count', async () => { const wrapper = mount(); await safeAct(wrapper); - expect(wrapper.find('.rc-table-measure-row td')).toHaveLength(5); + expect(wrapper.find('.rc-table-measure-row th')).toHaveLength(5); wrapper.setProps({ columns: columns.slice(0, 4) }); wrapper.update(); - expect(wrapper.find('.rc-table-measure-row td')).toHaveLength(4); + expect(wrapper.find('.rc-table-measure-row th')).toHaveLength(4); }); it('when all columns fixed left,cell should has classname rc-table-cell-fix-left-all', async () => { diff --git a/tests/__snapshots__/ExpandRow.spec.jsx.snap b/tests/__snapshots__/ExpandRow.spec.jsx.snap index 494f6d92d..2d85db84f 100644 --- a/tests/__snapshots__/ExpandRow.spec.jsx.snap +++ b/tests/__snapshots__/ExpandRow.spec.jsx.snap @@ -188,44 +188,44 @@ LoadedCheerio { - - - - - - - - - - - - - - - - - - - - shadow should be shown when there are columns where - - shadow should display correctly 1`] = ` - - shadow should display correctly 2`] = ` - - - -