Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Level three nodes cant have children #21

Open
matiasgarcia opened this issue Oct 29, 2015 · 10 comments
Open

Level three nodes cant have children #21

matiasgarcia opened this issue Oct 29, 2015 · 10 comments
Labels
Milestone

Comments

@matiasgarcia
Copy link

Consider the case of the following Tree:

  • Root
    • Level 1
      • Level 2 Node
      • Another Level 2 Node
    • New node

The component will not let me drag "New node" into any level 2 node. To do this, I have to drag out a level 2 node, drag the "New node" into it and then drag it back into level 1.

After doing this, the tree will end up like this:

  • Root
    • Level 1
      • Level 2 Node
      • Another Level 2 Node
        • New node

I have tried to debug why this is happening but couldn't find any solution. In the github page example, this behaviour happens too.

@tobyndockerill
Copy link

This is a result of the node having a leaf: true property.
If you set this to false (or don't give it the property at all) you will be able to drag nodes under it.

@matiasgarcia
Copy link
Author

No, this bug was found on previous version to the leaf feature.
I updated it and it still happens.

You can replicate this on the demo.

@wangzuo wangzuo added the bug label Oct 30, 2015
@matiasgarcia
Copy link
Author

I found the problem, but I am not really sure which is the proper way to fix this.

Since I have to render a really big tree, in the initial render I collapsed every single node it had.

In UITree Component, drag():

if(index.prev) {
                var prevNode = tree.getIndex(index.prev).node;
                if (!prevNode.collapsed && !prevNode.leaf) {
                    newIndex = tree.move(index.id, index.prev, 'append');
                }
            }
        }

As I said before, this has been happening before the leaf feature was added. So, if you have a collapsed node that doesn't have any children, it won't allow to append nodes to it.

Maybe check its children?

@wangzuo
Copy link
Contributor

wangzuo commented Nov 3, 2015

The component will not let me drag "New node" into any level 2 node

The level2 node has leaf: true ?

@matiasgarcia
Copy link
Author

Nope, as I said before, all tree nodes from level 1 to the end had collapse on true

@ulshv
Copy link

ulshv commented Apr 11, 2016

@matiasgarcia Did you find any solution?

@matiasgarcia
Copy link
Author

@sergeycooper Since I had a really big tree to render, I collapsed every single node on initialization. The issue was that I also collapsed the leaf nodes on initialization too, and this caused that new nodes couldnt be appended to them (check the code above). TL;DR I just avoided collapsing leaf nodes.

@ulshv
Copy link

ulshv commented Apr 11, 2016

@matiasgarcia Alright, I get it. Thanks for info!
Are you still using it or you find any other DnD-Tree-like solution?

@matiasgarcia
Copy link
Author

Although it has some perfomance issues to be solved when rendering a really big tree, I haven't found anything better. Let me know if you do :)

@ulshv
Copy link

ulshv commented Apr 11, 2016

If you haven't found anything better I think I will use it for my purposes too ;)

@wangzuo wangzuo added this to the 5.0 milestone Nov 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants