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
3 changes: 3 additions & 0 deletions src/Body/BodyRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import ExpandedRow from './ExpandedRow';
export interface BodyRowProps<RecordType> {
record: RecordType;
index: number;
renderIndex: number;
className?: string;
style?: React.CSSProperties;
recordKey: Key;
Expand All @@ -38,6 +39,7 @@ function BodyRow<RecordType extends { children?: readonly RecordType[] }>(
style,
record,
index,
renderIndex,
rowKey,
rowExpandable,
expandedKeys,
Expand Down Expand Up @@ -165,6 +167,7 @@ function BodyRow<RecordType extends { children?: readonly RecordType[] }>(
key={key}
record={record}
index={index}
renderIndex={renderIndex}
dataIndex={dataIndex}
render={render}
shouldCellUpdate={column.shouldCellUpdate}
Expand Down
3 changes: 2 additions & 1 deletion src/Body/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ function Body<RecordType>({
rowKey={key}
record={record}
recordKey={key}
index={renderIndex}
index={idx}
renderIndex={renderIndex}
rowComponent={trComponent}
cellComponent={tdComponent}
expandedKeys={expandedKeys}
Expand Down
7 changes: 5 additions & 2 deletions src/Cell/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ interface InternalCellProps<RecordType extends DefaultRecordType>
prefixCls?: string;
className?: string;
record?: RecordType;
/** `record` index. Not `column` index. */
/** `column` index is the real show rowIndex */
index?: number;
/** the index of the record. For the render(value, record, renderIndex) */
renderIndex?: number;
dataIndex?: DataIndex;
render?: ColumnType<RecordType>['render'];
component?: CustomizeComponent;
Expand Down Expand Up @@ -89,6 +91,7 @@ function Cell<RecordType extends DefaultRecordType>(
className,
record,
index,
renderIndex,
dataIndex,
render,
children,
Expand Down Expand Up @@ -131,7 +134,7 @@ function Cell<RecordType extends DefaultRecordType>(
// Customize render node
childNode = value;
if (render) {
const renderData = render(value, record, index);
const renderData = render(value, record, renderIndex);

if (isRenderCell(renderData)) {
if (process.env.NODE_ENV !== 'production') {
Expand Down
32 changes: 32 additions & 0 deletions tests/Table.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -988,4 +988,36 @@ describe('Table.Basic', () => {
expect(trs.at(4).find('Cell').at(1).text()).toEqual('0');
expect(trs.at(5).find('Cell').at(1).text()).toEqual('1');
});

it('hover the tree table', () => {
const tColumns = [
{
title: 'Key',
dataIndex: 'key',
},
];

const tData = [
{ key: 'row0', children: [{ key: 'row0-0' }, { key: 'row0-1' }] },
{ key: 'row1', children: [{ key: 'row1-0' }, { key: 'row1-1' }] },
];
const wrapper = mount(
<Table columns={tColumns} expandable={{ defaultExpandAllRows: true }} data={tData} />,
);

const trs = wrapper.find('tr.rc-table-row');

trs.forEach((tr, index) => {
tr.find('td.rc-table-cell').at(0).simulate('mouseEnter');
const currentClassName = wrapper
.find('tr.rc-table-row')
.at(index)
.find('td.rc-table-cell')
.at(0)
.getElement().props.className;

expect(currentClassName.includes('rc-table-cell-row-hover')).toEqual(true);
expect(wrapper.find('td.rc-table-cell-row-hover')).toHaveLength(1);
});
});
});