react-archer icon indicating copy to clipboard operation
react-archer copied to clipboard

Add support for optional arrow click handler and pointer cursor (#20)

Open robvenn opened this issue 5 years ago • 14 comments

Came up with the minimal required changes to add support for an onClick handler function prop. This will automatically add the cursor: pointer to the arrow stroke. For my use case it doesn't need the same on the arrow marker but just for the stroke (because multiple arrows can end in the same point), so not sure if those should be configurable separately for other use cases. I also passed by default the markerId, from.id, to.id besides the click event to the handler. Ideally it should also be possible to style a specific arrow when clicking (to set it as "selected").

robvenn avatar Dec 08 '18 23:12 robvenn

Thanks for the PR again 🤗 I'll review it asap!

pierpo avatar Dec 12 '18 14:12 pierpo

@robinvenneman Can you do a stupid example using your feature? (it can be really really stupid, look at the other examples hahaha) It will help me understand exactly what you want and helps me to check if anything went wrong. (until I set up proper automated tests)

pierpo avatar Dec 18 '18 23:12 pierpo

@robinvenneman Can you provide me an example or a use case? I'd like to know exactly what's needed to help you with this feature 😊

pierpo avatar Jan 02 '19 14:01 pierpo

@pierpo yeah what I did is just delete the relation when the arrow is clicked, most simple solution for what I was working on but ideally it would be able to do more I guess. I will see next week to find some time to add this example in the demo.

robvenn avatar Jan 05 '19 22:01 robvenn

@pierpo I've added a simple demo with clickable arrows, currently only the line is handling those events. The labels seem to intercept the pointer events on the arrow unless set to 'none' so this feature may require some more fine-tuning.

robvenn avatar Jan 13 '19 17:01 robvenn

@robinvenneman I am so sorry, I completely forgot to work on this. Is this still a feature you need?

pierpo avatar May 22 '19 15:05 pierpo

@pierpo Hey, no problem I also kind of forgot about this :) I implemented this on a private fork for this project I was working on and haven't looked at it since, not even sure if it's still in use right now.

If you think this is a good idea to add to the library then I still want to help out though if you'd like.

robvenn avatar May 22 '19 19:05 robvenn

Haha well I don't know, I wonder if having clickable arrows will happen often :thinking: I would suggest to wait for other people to ask for the feature before integrating it officially :blush:

pierpo avatar May 22 '19 20:05 pierpo

Ok, good idea :thumbsup:

robvenn avatar May 23 '19 06:05 robvenn

@pierpo definitely have a need for this. The use case here would be in the context of a flow chart. Allowing you to click on an arrow will allow you to add a new node in that particular position. Ideally, I should be able to add a '+' button with a click handler that sits on the middle of an arrow.

hashwin avatar Jul 06 '19 16:07 hashwin

@pierpo definitely have a need for this. The use case here would be in the context of a flow chart. Allowing you to click on an arrow will allow you to add a new node in that particular position. Ideally, I should be able to add a '+' button with a click handler that sits on the middle of an arrow.

Though, looks like this is already achievable using the 'label' option on a relation.

hashwin avatar Jul 06 '19 16:07 hashwin

@pierpo definitely have a need for this. The use case here would be in the context of a flow chart. Allowing you to click on an arrow will allow you to add a new node in that particular position. Ideally, I should be able to add a '+' button with a click handler that sits on the middle of an arrow.

Though, looks like this is already achievable using the 'label' option on a relation.

Yes indeed 😊 Glad that you found out a simple solution.

pierpo avatar Jul 08 '19 21:07 pierpo

We have a use case that needs clickable arrows, similar to the one described in #108. We need to make the arrows click-selectable to enable various interactions, but our arrows do not have a label. Enabling hover interactions on the arrows would be nice, too.

bobby avatar Oct 25 '21 21:10 bobby

My team will be happy to contribute to this PR, too, we're not expecting anything for free!

bobby avatar Oct 25 '21 21:10 bobby

Noted. I'll add this to my TODO!

I think we should start over, the PR is too old. The codebase has completely changed :smile:

pierpo avatar Sep 30 '22 09:09 pierpo

Closed in favor of https://github.com/pierpo/react-archer/pull/183 😊

pierpo avatar Nov 06 '22 20:11 pierpo

The PR was too old, so I started over. Thank you @robinv85 for your work, and sorry that it took me SO long to handle this 😴

pierpo avatar Nov 06 '22 20:11 pierpo