Skip to content

DnD for both node reordering and drop as child #181

@rmapes

Description

@rmapes

I would like to render the tree where each node can be at an arbitrary place in the hierarchy and dropping a node on another node makes it a child of that node.
I would also like to be able to reorder children by dragging within the child list.

At the moment, if I make all of the nodes internal nodes (i.e. they all have a child list which may be empty), then dropping a node on another node works fine (calls onMove with the target node as parent and an index of 0). However, dropping a node after another node also returns that node as a parent with an index of 0, unless the node both has children and is closed. This means that I can't implement the move behaviour consistently.

On the other hand, if I make all nodes with no children leaf nodes (by setting children to null if it is an empty array), I get the correct move behaviour (parent is parent of group and index is order within children) but I can no longer drop on the leaf nodes to create a child.

  1. Am I doing something wrong?
  2. If not, what's the best way to override the drop behaviour so that dropping on a leaf node will call onMove with that node as a parent.

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