Fix row selection when used with global filter

Fixes #1900
Closes #1937
This commit is contained in:
Tanner Linsley
2020-03-06 14:52:29 -07:00
parent c740a0c7af
commit 6d4a733a88
2 changed files with 17 additions and 18 deletions
+7 -9
View File
@@ -237,19 +237,17 @@ function useInstance(instance) {
// We technically could do this recursively in the above loop,
// but that would severely hinder the API for the user, since they
// would be required to do that recursion in some scenarios
filteredRows = filteredRows.map(row => {
filteredRows.forEach(row => {
filteredFlatRows.push(row)
filteredRowsById[row.id] = row
if (!row.subRows) {
return row
}
return {
...row,
subRows:
row.subRows && row.subRows.length > 0
? filterRows(row.subRows, depth + 1)
: row.subRows,
return
}
row.subRows =
row.subRows && row.subRows.length > 0
? filterRows(row.subRows, depth + 1)
: row.subRows
})
return filteredRows
+10 -9
View File
@@ -107,22 +107,23 @@ function useInstance(instance) {
// Filters top level and nested rows
const filterRows = filteredRows => {
return filterMethod(
filteredRows = filterMethod(
filteredRows,
allColumns.map(d => d.id),
globalFilterValue
).map(row => {
)
filteredRows.forEach(row => {
filteredFlatRows.push(row)
filteredRowsById[row.id] = row
return {
...row,
subRows:
row.subRows && row.subRows.length
? filterRows(row.subRows)
: row.subRows,
}
row.subRows =
row.subRows && row.subRows.length
? filterRows(row.subRows)
: row.subRows
})
return filteredRows
}
return [filterRows(rows), filteredFlatRows, filteredRowsById]