N00ts / vue3-treeview

a simple treeview in vue js 3
MIT License
71 stars 61 forks source link

Can we trigger an node edit event #37

Open alokswain opened 1 year ago

alokswain commented 1 year ago

We want to add a edit icon to a node which can trigger the node edit like doubleclick does. It will make the feature very easily discoverable. The button can be added via slot but can I trigger the node edit event

<template #after-input="props">
    <span class="actions">
    <span class="edit_node" @click="triggerNodeEdit(props)">Edit</span>
 </span>

any ideas as to how I can achieve this ?

alokswain commented 1 year ago

Hi @N00ts - Any ideas on how to achieve this.

I tried triggering the dblclick event as below but could not.

triggerNodeEdit(event, props){
       var dblClickEvent = new MouseEvent('click', {
         'view': window,
         'bubbles': true,
         'cancelable': true
       });
      event.target.parentNode.parentNode.parentNode.querySelector(".input-wrapper").querySelector(".node-text").dispatchEvent(dblClickEvent);
}