Skip to content

getFacetedRowModel inconsistently respects maxLeafRowFilterDepth: 0 #5987

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
2 tasks done
Mark-Triffin opened this issue Apr 9, 2025 · 0 comments
Open
2 tasks done

Comments

@Mark-Triffin
Copy link

TanStack Table version

v8.20.6

Framework/Library version

v18.3.1

Describe the bug and the steps to reproduce it

Hi,

I have the following setup for the table:

const table = useReactTable({
    data,
    columns,
    getRowId: (row, _, parent) => (parent ? [parent.original._id, row._id].join(".") : row._id),
    getCoreRowModel: getCoreRowModel(),
    getFilteredRowModel: getFilteredRowModel(),
    getFacetedRowModel: getFacetedRowModel(),
    getFacetedUniqueValues: getFacetedUniqueValues(),
    getSubRows: (row) => row?.products?.flatMap((p: { product: TProduct }) => (p?.product?.name ? [p.product] : [])),
    columnResizeMode: "onChange",
    autoResetPageIndex: false,
    maxLeafRowFilterDepth: 0,
  });

And elsewhere I have components for filtering that use table.getColumn("columnName")?.getFacetedUniqueValues() in order to show the amount of items that will be filters.

I've found then before any filtering is applied the facet counts include all items at every level of the array that match, but after a filter is applied only the items at the top of the tree are counted (even though all items still show due to the maxLeafRowFilterDepth: 0). This seems incorrect.

My hope is that the getFacetedUniqueValues could support maxLeafRowFilterDepth. However, even if not I believe that consistency between before and after filtering is important.

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

https://codesandbox.io/p/devbox/charming-bush-lcnqhz

Screenshots or Videos (Optional)

No response

Do you intend to try to help solve this bug with your own PR?

None

Terms & Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant