TanStack / table

🤖 Headless UI for building powerful tables & datagrids for TS/JS - React-Table, Vue-Table, Solid-Table, Svelte-Table
https://tanstack.com/table
MIT License
24.89k stars 3.07k forks source link

Faceted Unique Values is empty when `filterFromLeafRows` is set #4768

Closed jochenschmich-aeberle closed 1 year ago

jochenschmich-aeberle commented 1 year ago

Describe the bug

The example in https://tanstack.com/table/v8/docs/examples/react/filters should also fully work, when filterFromLeafRows is set to true.

As soon as the first filter value has been entered, the table is still correctly filtered, but the count of faceted unique values reads 0.

Your minimal, reproducible example

https://codesandbox.io/p/sandbox/still-waterfall-n82b2q

Steps to reproduce

  1. Add a filter value to firstName that is so generic, that some rows would still be shown, e.g. "a"
  2. All column filter inputs read "Search... (0)"

Expected behavior

All column filter inputs should read "Search... (437)" (where 437 is a valid value)

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

Windows, Edge

react-table version

latest

TypeScript version

No response

Additional context

I think the problem lies here: https://github.com/TanStack/table/blob/main/packages/table-core/src/utils/filterRowsUtils.ts#L65 AFAIK this line should rather read newFilteredFlatRows.push(row) like in the corresponding lines in filterRowModelFromRoot.

Terms & Code of Conduct

jochenschmich-aeberle commented 1 year ago

Updated to current version of the code... This could be a quick fix, I suppose...