primefaces / primereact

The Most Complete React UI Component Library
https://primereact.org
MIT License
6.93k stars 1.05k forks source link

TreeNode: expanded does not work #7435

Open nimo23 opened 3 days ago

nimo23 commented 3 days ago

Describe the bug

According to https://github.com/primefaces/primereact/issues/606, we should use expandedKeys to expand the nodes by default.

But according to https://primereact.org/treetable/#api.TreeNode, we can also set expanded property when setting a TreeNode, for example:

const myNode: TreeNode = {
    id: myId,
    key: myId,
    label: myLabel,
    data: { name: name, type: "task" },
    icon: 'pi pi-fw pi-inbox',
    expanded: true, // DOES NOT WORK
    children: [{
        id: "child1",
        key: "child1",
        label: "chld",
        data: { name: "child1" },
        icon: 'pi pi-fw pi-inbox',
        expanded: true,
        children: []
    }]
};

However, after setting to myNode.expanded = true, the node is not expanded.

Reproducer

No response

System Information

"primereact": "^10.8.4",
"react": "^18.3.1",
"react-dom": "^18.3.1",

Steps to reproduce the behavior

No response

Expected behavior

Make TreeNode#expanded work.