MandarinConLaBarba / react-tree-menu

A stateless tree menu component for React.
http://mandarinconlabarba.github.io/react-tree-menu/example/index.html
MIT License
170 stars 51 forks source link

Setting collapsed: true in data breaks stateful tree-menu #16

Closed vsaportas closed 9 years ago

vsaportas commented 9 years ago

I am setting collapsed true in the initial data array. When I render the component I am unable to expand the node. Without setting collapsed true I can expand and collapse as expected.

data= [
  {label: 'node1', collapsed: true, children: [
    {label: 'node2'},
    {label: 'node3'},
  ]}
]

<div>
  <TreeMenu
    stateful={true}
    onTreeNodeClick={onTreeNodeClick}
    onTreeNodeCollapseChange={onTreeNodeCollapseChange}
    onTreeNodeCheckChange={onTreeNodeCheckChange}
    expandIconClass="fa fa-chevron-right"
    collapseIconClass="fa fa-chevron-down"
    data={data} />
</div>

I suspect the stateful collapsed variable is being overwritten by the props collapsed variable in tree_node but couldn't quite figure it out from glancing at the project code.