Closed chisholmd closed 6 years ago
Sorry I have never submited to a github project so I am just going to post my suggestion here for now ok.
Here is what I did so that I can add "selected" to my tree data:
In paper-tree-node.html
129:
Then added this: connectedCallback() { super.connectedCallback(); if(this.selected){ this.select() } }
Then in my tree data I can just set an item as "selected": true Seems to work ok for me.
The thing is the selected state is managed globally by the tree. With your proposal we cannot guarantee the uniqueness of selected, it will probably dispatch unwanted select
event and we will run into issues. A node cannot decide by itself to be selected (imagine the user is working in a sibling subtree, he will loose the focus/selected state). This breaks the main principle of the component. If I did not understand well your request, don't hesitate to re-open the issue.
I am not sure how else to phrase it....I need to be able to load the tree for the user with a specific folder already selected.
Imagine this URL
http://myapp#browse?path=alpha%2Fbeta%2Fgamma
When the tree loads the folders "alpha" and "beta" and "gamma" need to have their open property set
AND the "gamma" folder needs to be "selected". Normally this would be passed in with the JSON representation of the tree and the folder would have a selected property.
By not having a selected property it seems like your saying that only the user can "select" a folder and the system can never load a state with a folder selected.
Check out the json for the jsTree it is very rich and stable https://www.jstree.com/docs/json/
{ id : "string" // will be autogenerated if omitted text : "string" // node text icon : "string" // string for custom state : { opened : boolean // is the node open disabled : boolean // is the node disabled selected : boolean // is the node selected }, children : [] // array of strings or objects li_attr : {} // attributes for the generated LI node a_attr : {} // attributes for the generated A node }
The data uses an "open" property but doesn't it also need a "selected" property? If I am reloading a path I need to display all the correct folders as opened, and the target folder as selected.