Skip to content

getFacetedRowModel inconsistently respects maxLeafRowFilterDepth: 0 #5987

Open
@Mark-Triffin

Description

@Mark-Triffin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions