naisutech / react-tree

Hierarchical tree component for React in Typescript
https://naisutech.github.io/react-tree/
MIT License
206 stars 25 forks source link

Right click behavior #82

Closed martinRenou closed 2 years ago

martinRenou commented 2 years ago

Thanks for this extension!

I'd like to implement a right-click behavior on my tree. It would be useful to have some kind of onClick property which would accept a callback like (e: MouseEvent, id: TreeNodeId) => void.

Is this possible already?

ortonomy commented 2 years ago

Hi, @martinRenou - thanks for opening this issue. I had no plans to add an onclick event, but if others ask for it, I can.

You should be able to pass a custom renderer and the you can bind a click listener to the elements you render there. Don't forget to stop the propagation, though. Otherwise the click listeners for open/and select will still fire.