Skip to content

Reordering node under root #31

@Giatomo

Description

@Giatomo

I got some issues while moving nodes right under the root node. Mostly the concat function not working here (on jstreer.js at $el.on("move_node.jstree", function(e, data)) :

var oldPath = oldInstance
              .get_path(data.old_parent)
              .concat(nodeText);

Exemple tree :

# (root node)
- A (child node)
- B
- C

I figured out a solution that would improve the consistancy of the jsTreeMoved event of the "from" and the "to" values while also retrieve the positions of the nodes (which is important in my use case but might also be helpful to other users) :
on $el.on("move_node.jstree", function(e, data) :

Shiny.setInputValue("jsTreeMoved:jsTreeR.copied", {
              from: { instance: oldInstanceId, path: oldPath },
              to: { instance: newInstanceId, path: newPath }
            }, {priority: "event"});

can be replaced by either :

Shiny.setInputValue("jsTreeMoved:jsTreeR.copied",{
              from: {
                instance: oldInstanceId,
                parent: data.old_parent,
                path: oldInstance.get_path(node),
                position: data.old_position},
              to: { 
                instance: newInstanceId,
                parent: data.parent,
                path: newInstance.get_path(node),
                position: data.position}
            }, {priority: "event"});

or :

Shiny.setInputValue("jsTreeMoved:jsTreeR.copied"{
              from: {
                instance: oldInstanceId,
                path: [data.old_parent].concat(oldInstance.get_path(node)),
                position: data.old_position},
              to: { 
                instance: newInstanceId,
                path: [data.parent].concat(newInstance.get_path(node)),
                position: data.position}
            }, {priority: "event"});

Thank for looking into this issue !
Best regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions