Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useLabels hook? #2522

Closed
tisoap opened this issue Oct 23, 2022 · 3 comments
Closed

useLabels hook? #2522

tisoap opened this issue Oct 23, 2022 · 3 comments
Labels
feature request New feature or request

Comments

@tisoap
Copy link

tisoap commented Oct 23, 2022

Please describe the feature that you want to propose

I'm the author of React Flow Smart Edge. Right now I'm using useNodes hook to get all nodes in the graph to do path finding on my custom edge. It would be great if React Flow could also provide me with a useLabels hook to return all "label" elements and their information (size and position), so that I can also include them on the path finding logic and make my custom edge avoid intersecting with them.

@moklick
Copy link
Member

moklick commented Oct 24, 2022

Hey @tisoap ! This is an interesting idea but we won't add this feature. The edge labels are defined in the edge components and it's really hard to get that information in an performant way. If you really need this you need to implement your own helper function for this. I think there is no other way right now than do some calculations with the help of getBBox whenever the nodes change.

@tisoap
Copy link
Author

tisoap commented Oct 24, 2022

@moklick Understandable. I think what I'll end up doing is some form of inversion of control where users can pass down areas on the graph to avoid, and let up to them if it's worth to track the position of every label of their graph

@moklick
Copy link
Member

moklick commented Oct 25, 2022

That's a good idea!

@moklick moklick closed this as completed Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants