Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/VirtualTable/BodyLine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ const BodyLine = React.forwardRef<HTMLDivElement, BodyLineProps>((props, ref) =>
// ========================== Expand ==========================
const { rowSupportExpand, expanded, rowProps, expandedRowRender, expandedRowClassName } = rowInfo;

const expandedClsName = computedExpandedClassName(expandedRowClassName, record, index, indent);

let expandRowNode: React.ReactElement<any>;
if (rowSupportExpand && expanded) {
const expandContent = expandedRowRender(record, index, indent + 1, expanded);

const expandedClsName = computedExpandedClassName(expandedRowClassName, record, index, indent);

let additionalProps: React.TdHTMLAttributes<HTMLElement> = {};
if (fixColumn) {
additionalProps = {
Expand Down Expand Up @@ -94,6 +94,7 @@ const BodyLine = React.forwardRef<HTMLDivElement, BodyLineProps>((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 }}
Expand Down
26 changes: 26 additions & 0 deletions tests/Virtual.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: () => <span className="custom-expand-icon" />,
},
});

expect(container.querySelector('[data-row-key="child"]')).toHaveClass('bamboo');
});

it('fixed', () => {
const { container } = getTable({
columns: [
Expand Down
Loading