Skip to content

Commit

Permalink
Fix: filterFromLeafRows (#4376)
Browse files Browse the repository at this point in the history
* fix: filterFromLeafRows

* tidyup
  • Loading branch information
rek committed Nov 12, 2022
1 parent 6fcaeed commit a368e24
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 deletions packages/table-core/src/utils/filterRowsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,39 @@ export function filterRowModelFromLeafs<TData extends RowData>(
for (let i = 0; i < rowsToFilter.length; i++) {
let row = rowsToFilter[i]!

const newRow = createRow(
table,
row.id,
row.original,
row.index,
row.depth
)
newRow.columnFilters = row.columnFilters

if (row.subRows?.length) {
const newRow = createRow(
table,
row.id,
row.original,
row.index,
row.depth
)
newRow.columnFilters = row.columnFilters
newRow.subRows = recurseFilterRows(row.subRows, depth + 1)
if (!newRow.subRows.length) {
row = newRow

if (filterRow(row) && !newRow.subRows.length) {
rows.push(row)
newFilteredRowsById[row.id] = row
newFilteredRowsById[i] = row
continue
}
row = newRow
}

if (filterRow(row)) {
rows.push(row)
newFilteredRowsById[row.id] = row
newFilteredRowsById[i] = row
if (filterRow(row) || newRow.subRows.length) {
rows.push(row)
newFilteredRowsById[row.id] = row
newFilteredRowsById[i] = row
continue
}
} else {
row = newRow
if (filterRow(row)) {
rows.push(row)
newFilteredRowsById[row.id] = row
newFilteredRowsById[i] = row
}
}
}

Expand Down

0 comments on commit a368e24

Please sign in to comment.