React-sortable-tree: How to implement canExpand?

Created on 27 May 2018  路  6Comments  路  Source: frontend-collective/react-sortable-tree

How do you implement canExpand? With the file-browser analogy, I do not want to offer expanded file nodes during drag and drop. Yes, it is displayed in red, if you implement canDrop, but I'd like a "file" like node to not even expand, as it's only ever meant to be a leaf node.

enhancement question

Most helpful comment

@wuweiweiwu , @hyperknot I will post a pr for this

All 6 comments

hi @hyperknot.

If you set the expanded property on each node to false in treeData prop and also on onChange call backs. then the node with expanded set to false would never expand.

Hope that helps!

Hi @wuweiweiwu,

I've set expanded to false for each "file" like node, didn't make a difference. onChange is only run after a drop has happened, thus I cannot see how would it avoid opening file like nodes while dragging.

sortable

oh I see.I think we would need to add a new attribute (ie canExpand) that decides if a node can be expanded or not. and that attribute will be check during the drag phase

@wuweiweiwu , @hyperknot I will post a pr for this

@lifejuggler still planning to do a PR?

sorry I just moved to a new job and been super busy... you can do it

Was this page helpful?
0 / 5 - 0 ratings

Related issues

2503shubham picture 2503shubham  路  3Comments

brendanmoore picture brendanmoore  路  5Comments

theonelucas picture theonelucas  路  3Comments

jorgecuesta picture jorgecuesta  路  4Comments

LogicMonsters picture LogicMonsters  路  5Comments