expandNode/collapseNode does not seems to work when parent node is not expandable
Hello,
It seems that when the root node is not expandable, but always expanded (aka user should not be able to collapse it), expandNode/collapseNode does not work
here is the codesandbox : https://codesandbox.io/s/vuejs-tree-sandbox-v3-x-forked-snei99?file=/src/components/TreeExample.vue
if i toggle expandable on the root node, it works, but it's seems to be recursive, collapse of the child node seems to collapse the parent node, expand of the parent does not expand the child however
it seems that the issue is here : https://github.com/vinz3872/vuejs-tree/blob/c6c50965181939bc8f6aa2b5022d30f480e0b0f6/src/components/helper.ts#L27
i would change to :
const disabledStateKey = (disabledState as any)[event]
if (disabledStateKey && node[disabledStateKey] === false && node.state[event] === false) {
return
}
In the end i think that when a node is not expandable but it's expanded anyway, it should go through
The solution i will do for now, is to set expandable to true, and remove the icon with js :
this.$el.querySelector('#tree > ul > li > div > span:nth-child(1) > i').remove()
and i also need to reopen the root node after collapsing child nodes
thanks
Hello,
Indeed i never found a use case when the node is already expanded but can't (or shouldn't) be collapsed, I'll fix it really soon
In the meantime, do you really need to expand / collapse the nodes manually ? (because it work if you keep the default behavior via a click on the tree)
I don't need to set the fn function on the expanded event, you are right, but its easier because i need to setup dragover/drop listeners when expanded, because i use the tree as a folder explorer, and user can drag an drop files to it
But for now it works the way i did it so its fine, i set expandable to true and remove the chevron