holiber / sl-vue-tree

Customizable draggable tree component for Vue.js
https://holiber.github.io/sl-vue-tree/
MIT License
345 stars 78 forks source link

Combining nodecontextmenu and nodeclick. #44

Closed volodymyrradchenko closed 5 years ago

volodymyrradchenko commented 5 years ago

Currently, item's not getting selected if you click on it with the right mouse button. Is it possible to add nodeclick event right before nodecontextmenu is getting fired if one or less items are selected. Also, let it behave as it does currently if more than 1 items selected?

holiber commented 5 years ago

You can manually select the item in the nodecontextmenu handler. Look at the demo in dark-theme.html

      showContextMenu(node, event) {
        event.preventDefault();
        this.contextMenuIsVisible = true;
        const $contextMenu = this.$refs.contextmenu;
        $contextMenu.style.left = event.clientX + 'px';
        $contextMenu.style.top = event.clientY + 'px';
        this.$refs.slVueTree.select(node.path); // <-- add this line to select current node
      },
volodymyrradchenko commented 5 years ago

It helped, thank you! Feels like pure magic