@@ -22,7 +22,11 @@ export function filterRowModelFromLeafs<TData extends RowData>(
22
22
const newFilteredRowsById : Record < string , Row < TData > > = { }
23
23
const maxDepth = table . options . maxLeafRowFilterDepth ?? 100
24
24
25
- const recurseFilterRows = ( rowsToFilter : Row < TData > [ ] , depth = 0 ) => {
25
+ const recurseFilterRows = (
26
+ rowsToFilter : Row < TData > [ ] ,
27
+ depth = 0 ,
28
+ parentRow ?: Row < TData >
29
+ ) => {
26
30
const rows : Row < TData > [ ] = [ ]
27
31
28
32
// Filter from children up first
@@ -34,12 +38,14 @@ export function filterRowModelFromLeafs<TData extends RowData>(
34
38
row . id ,
35
39
row . original ,
36
40
row . index ,
37
- row . depth
41
+ row . depth ,
42
+ undefined ,
43
+ parentRow
38
44
)
39
45
newRow . columnFilters = row . columnFilters
40
46
41
47
if ( row . subRows ?. length && depth < maxDepth ) {
42
- newRow . subRows = recurseFilterRows ( row . subRows , depth + 1 )
48
+ newRow . subRows = recurseFilterRows ( row . subRows , depth + 1 , newRow )
43
49
row = newRow
44
50
45
51
if ( filterRow ( row ) && ! newRow . subRows . length ) {
@@ -85,7 +91,11 @@ export function filterRowModelFromRoot<TData extends RowData>(
85
91
const maxDepth = table . options . maxLeafRowFilterDepth ?? 100
86
92
87
93
// Filters top level and nested rows
88
- const recurseFilterRows = ( rowsToFilter : Row < TData > [ ] , depth = 0 ) => {
94
+ const recurseFilterRows = (
95
+ rowsToFilter : Row < TData > [ ] ,
96
+ depth = 0 ,
97
+ parentRow ?: Row < TData >
98
+ ) => {
89
99
// Filter from parents downward first
90
100
91
101
const rows : Row < TData > [ ] = [ ]
@@ -103,9 +113,11 @@ export function filterRowModelFromRoot<TData extends RowData>(
103
113
row . id ,
104
114
row . original ,
105
115
row . index ,
106
- row . depth
116
+ row . depth ,
117
+ undefined ,
118
+ parentRow
107
119
)
108
- newRow . subRows = recurseFilterRows ( row . subRows , depth + 1 )
120
+ newRow . subRows = recurseFilterRows ( row . subRows , depth + 1 , newRow )
109
121
row = newRow
110
122
}
111
123
0 commit comments