mirror of
https://github.com/gosticks/react-table.git
synced 2026-12-03 11:11:39 +00:00
Fix row selection when used with global filter
Fixes #1900 Closes #1937
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user