File tree Expand file tree Collapse file tree 4 files changed +42
-3
lines changed Expand file tree Collapse file tree 4 files changed +42
-3
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import ExpandedRow from './ExpandedRow';
16
16
export interface BodyRowProps < RecordType > {
17
17
record : RecordType ;
18
18
index : number ;
19
+ renderIndex : number ;
19
20
className ?: string ;
20
21
style ?: React . CSSProperties ;
21
22
recordKey : Key ;
@@ -38,6 +39,7 @@ function BodyRow<RecordType extends { children?: readonly RecordType[] }>(
38
39
style,
39
40
record,
40
41
index,
42
+ renderIndex,
41
43
rowKey,
42
44
rowExpandable,
43
45
expandedKeys,
@@ -165,6 +167,7 @@ function BodyRow<RecordType extends { children?: readonly RecordType[] }>(
165
167
key = { key }
166
168
record = { record }
167
169
index = { index }
170
+ renderIndex = { renderIndex }
168
171
dataIndex = { dataIndex }
169
172
render = { render }
170
173
shouldCellUpdate = { column . shouldCellUpdate }
Original file line number Diff line number Diff line change @@ -71,7 +71,8 @@ function Body<RecordType>({
71
71
rowKey = { key }
72
72
record = { record }
73
73
recordKey = { key }
74
- index = { renderIndex }
74
+ index = { idx }
75
+ renderIndex = { renderIndex }
75
76
rowComponent = { trComponent }
76
77
cellComponent = { tdComponent }
77
78
expandedKeys = { expandedKeys }
Original file line number Diff line number Diff line change @@ -43,8 +43,10 @@ interface InternalCellProps<RecordType extends DefaultRecordType>
43
43
prefixCls ?: string ;
44
44
className ?: string ;
45
45
record ?: RecordType ;
46
- /** `record ` index. Not `column` index. */
46
+ /** `column ` index is the real show rowIndex */
47
47
index ?: number ;
48
+ /** the index of the record. For the render(value, record, renderIndex) */
49
+ renderIndex ?: number ;
48
50
dataIndex ?: DataIndex ;
49
51
render ?: ColumnType < RecordType > [ 'render' ] ;
50
52
component ?: CustomizeComponent ;
@@ -89,6 +91,7 @@ function Cell<RecordType extends DefaultRecordType>(
89
91
className,
90
92
record,
91
93
index,
94
+ renderIndex,
92
95
dataIndex,
93
96
render,
94
97
children,
@@ -131,7 +134,7 @@ function Cell<RecordType extends DefaultRecordType>(
131
134
// Customize render node
132
135
childNode = value ;
133
136
if ( render ) {
134
- const renderData = render ( value , record , index ) ;
137
+ const renderData = render ( value , record , renderIndex ) ;
135
138
136
139
if ( isRenderCell ( renderData ) ) {
137
140
if ( process . env . NODE_ENV !== 'production' ) {
Original file line number Diff line number Diff line change @@ -988,4 +988,36 @@ describe('Table.Basic', () => {
988
988
expect ( trs . at ( 4 ) . find ( 'Cell' ) . at ( 1 ) . text ( ) ) . toEqual ( '0' ) ;
989
989
expect ( trs . at ( 5 ) . find ( 'Cell' ) . at ( 1 ) . text ( ) ) . toEqual ( '1' ) ;
990
990
} ) ;
991
+
992
+ it ( 'hover the tree table' , ( ) => {
993
+ const tColumns = [
994
+ {
995
+ title : 'Key' ,
996
+ dataIndex : 'key' ,
997
+ } ,
998
+ ] ;
999
+
1000
+ const tData = [
1001
+ { key : 'row0' , children : [ { key : 'row0-0' } , { key : 'row0-1' } ] } ,
1002
+ { key : 'row1' , children : [ { key : 'row1-0' } , { key : 'row1-1' } ] } ,
1003
+ ] ;
1004
+ const wrapper = mount (
1005
+ < Table columns = { tColumns } expandable = { { defaultExpandAllRows : true } } data = { tData } /> ,
1006
+ ) ;
1007
+
1008
+ const trs = wrapper . find ( 'tr.rc-table-row' ) ;
1009
+
1010
+ trs . forEach ( ( tr , index ) => {
1011
+ tr . find ( 'td.rc-table-cell' ) . at ( 0 ) . simulate ( 'mouseEnter' ) ;
1012
+ const currentClassName = wrapper
1013
+ . find ( 'tr.rc-table-row' )
1014
+ . at ( index )
1015
+ . find ( 'td.rc-table-cell' )
1016
+ . at ( 0 )
1017
+ . getElement ( ) . props . className ;
1018
+
1019
+ expect ( currentClassName . includes ( 'rc-table-cell-row-hover' ) ) . toEqual ( true ) ;
1020
+ expect ( wrapper . find ( 'td.rc-table-cell-row-hover' ) ) . toHaveLength ( 1 ) ;
1021
+ } ) ;
1022
+ } ) ;
991
1023
} ) ;
You can’t perform that action at this time.
0 commit comments