From 8e26cb4f5c6bb0bb6c43d58d6402735f3ee2e699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E8=89=B3=E5=85=B5?= Date: Thu, 23 Apr 2026 22:27:21 +0800 Subject: [PATCH] fix: apply expandedRowClassName to virtual tree rows --- src/VirtualTable/BodyLine.tsx | 5 +++-- tests/Virtual.spec.tsx | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/VirtualTable/BodyLine.tsx b/src/VirtualTable/BodyLine.tsx index f3a507353..d072c6954 100644 --- a/src/VirtualTable/BodyLine.tsx +++ b/src/VirtualTable/BodyLine.tsx @@ -39,12 +39,12 @@ const BodyLine = React.forwardRef((props, ref) => // ========================== Expand ========================== const { rowSupportExpand, expanded, rowProps, expandedRowRender, expandedRowClassName } = rowInfo; + const expandedClsName = computedExpandedClassName(expandedRowClassName, record, index, indent); + let expandRowNode: React.ReactElement; if (rowSupportExpand && expanded) { const expandContent = expandedRowRender(record, index, indent + 1, expanded); - const expandedClsName = computedExpandedClassName(expandedRowClassName, record, index, indent); - let additionalProps: React.TdHTMLAttributes = {}; if (fixColumn) { additionalProps = { @@ -94,6 +94,7 @@ const BodyLine = React.forwardRef((props, ref) => data-row-key={rowKey} ref={rowSupportExpand ? null : ref} className={clsx(className, `${prefixCls}-row`, rowProps?.className, { + [expandedClsName]: indent >= 1, [`${prefixCls}-row-extra`]: extra, })} style={{ ...rowStyle, ...rowProps?.style }} diff --git a/tests/Virtual.spec.tsx b/tests/Virtual.spec.tsx index dad854b21..a05904de3 100644 --- a/tests/Virtual.spec.tsx +++ b/tests/Virtual.spec.tsx @@ -183,6 +183,32 @@ describe('Table.Virtual', () => { }); }); + it('applies expanded row class to tree rows', () => { + const { container } = getTable({ + data: [ + { + name: 'parent', + age: 0, + address: 'address0', + children: [ + { + name: 'child', + age: 1, + address: 'address1', + }, + ], + }, + ], + expandable: { + expandedRowKeys: ['parent'], + expandedRowClassName: 'bamboo', + expandIcon: () => , + }, + }); + + expect(container.querySelector('[data-row-key="child"]')).toHaveClass('bamboo'); + }); + it('fixed', () => { const { container } = getTable({ columns: [