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

Using sort: 'text' doesn't retain proper order #13

Closed
troywoy opened this issue Dec 17, 2015 · 7 comments
Closed

Using sort: 'text' doesn't retain proper order #13

troywoy opened this issue Dec 17, 2015 · 7 comments

Comments

@troywoy
Copy link

troywoy commented Dec 17, 2015

While the title may not make sense, I hope that the details here make it crystal clear.

When creating a tree with sort: 'text' applied to the configuration and supplying data in an array that is out of order, keyboard navigation (more specifically nextVisibleNode, previousVisibleNode, etc) fails to return the proper node.

Consider this configuration:

var tree = new InspireTree({
    target: '.tree',
    sort: 'text',
    data: [{
        text: 'A',
    }, {
        text: 'C'
    }, {
        text: 'B'
    }]
});

Then tree.nodes()[1] would give me node B, however calling tree.nodes()[1].nextVisibleNode() would give me undefined since it was last in the original data array. I would expect that to give me C since it's visually the next one.

I can create a JSFiddle if you have trouble recreating this.

@troywoy
Copy link
Author

troywoy commented Dec 17, 2015

Well that's frustrating, I might've put my foot in my mouth. I made this fiddle, which contradicts the issue I've filed.

The only difference I have between my issue and the fiddle is that I'm using a custom Angular renderer.

Thoughts?

PS: Sorry the fiddle is ugly, I don't know a better way to include libraries that aren't available over a CDN.

@troywoy
Copy link
Author

troywoy commented Dec 17, 2015

Alright, I was able to recreate it in this fiddle using my test data. Apparently sort: 'text' has nothing to do with this (I was making an assumption, sorry).

If you expand all nodes and move down the tree with the down arrow, you get stuck on Rodger Federer. If you move up the tree, it skips the children of Tennis entirely. If you collapse Tennisthen you can traverse up and down without issue. Not sure what the issue is here anymore, but at least I have a "broken" scenario for you.

@viveleroi
Copy link
Contributor

Both "broken" and "working" examples fail for me, but I see why these aren't working. I can have a fix tomorrow morning.

@viveleroi
Copy link
Contributor

I have a fix for this in place. Just need to write some tests tomorrow.

Also, I've requested that inspire-tree be included in the cdnjs.com library. That way you have a cdn url to the files you can link to in jsbin/fiddle demos.

@troywoy
Copy link
Author

troywoy commented Dec 17, 2015

Yeah I didn't name those properly. Both were broken, I just wanted to ensure data that wasn't in the proper order was the root cause.

@onack
Copy link

onack commented Nov 1, 2016

I have the same issue with 1.10.3 if I add elements after tree is initialized

Example: https://jsfiddle.net/3v5wL01u/1/

@viveleroi
Copy link
Contributor

@onack I've moved your issue to #78 because while it involves sorting, it's unrelated to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants