primefaces / primefaces/primereact

TreeTable/Tree: filtering should use content of `TreeNode.data` (if defined)

Open
#7,460 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Status: Discussion
Dominant language
CSS
Stars
8.3k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

Defining a TreeNode for TreeTable (or Tree) as follows:

const userNode: TreeNode = {
    key: user.id,
    label: user.username,
    data: {
        name: (
        <div>
            <i className="pi pi-user pr-2"></i>
            <span>{user.username}</span>
        </div>
    ),
..

with column:

<Column field="name" header="" expander>

will render the Tree correctly. However, when having custom jsx in the data.name field, the TreeTable.globalFilter does not work anymore.

The filtering works when using a TreeNode without custom jsx:

const userNode: TreeNode = {
    key: user.id,
    label: user.username,
    data: {
        name: user.username,
..
Reproducer

No response

System Information
primereact 10.8.3
Steps to reproduce the behavior
  1. Setup a TreeTable (or Tree) with a TreeNode like above
  2. Add globalFilter to TreeTable (with state-hook) and input field:

<InputText type="search" placeholder="Search" onChange={e => setGlobalFilter(e.target.value)} />

  1. Test the filter.
Expected behavior

The filtering should filter the content of TreeNode.data-fields.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the TreeTable and Tree filtering entry points, focusing on globalFilter and how TreeNode.data values are read. Reproduce the issue with a data.name value containing JSX, then verify that filtering matches the rendered content while preserving the existing behavior for plain strings.

Written by the indexing model from the issue text.

Assessment

Tech stack
react
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.