Open zealan-spender opened 4 years ago
I have a workaround for this. Right clicking a node should definitely select the node first, but the default behavior is not to. Luckily the workaround is straightforward. Drill into the sl-vue-tree
API via its ref and manually select the target node on right click:
<template>
<sl-vue-tree @nodecontextmenu="onNodeRightClicked" ref="tree"/>
</template>
<script>
export default {
methods: {
onNodeRightClicked(node, e) {
e.preventDefault()
//get the tree reference
const tree = this.$refs.tree
//use the API to select the node
tree.select(node.path)
//do the rest of your work
}
}
}
</script>
I'd really like to see this fabulous library updated to do this automatically, since there's no need for a context menu with no context!
I've discovered that right-clicking does not select the node, therefore clicking 'Remove' from the contextmenu will not remove the node unless node is previously selected.
So the example with contextmenu should be updated in order to work:
showContextMenu(node, event) { event.preventDefault(); const $slVueTree = this.$refs.slVueTree; $slVueTree.select( node.path ); ...