No way for client code to tell if a target handle is connectable #824
snoozbuster
started this conversation in
Ideas
Replies: 1 comment 12 replies
-
Connectable handles have a class name called document.querySelector(`[data-handleid="${handleId}"].connectable`) to find a handle element that's connectable. Or if you just need to validate if that element is connectable this would do it as well document.querySelector(`[data-handleid="${handleId}"]`).classList.contains('connectable') |
Beta Was this translation helpful? Give feedback.
12 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm writing a custom connection line which allows users to drag edges directly onto a node and automatically have the edge connect to the input handle (in my project, there is only ever one). The code I've written for this looks like so:
In the
if
statement where I decide if I should make the connection, all I can really do is check if the handle exists. I don't have any way to actually check if the handle is connectable or not. Ideally I would like to re-use something likeisValidHandle
, but that function isn't really useable as-is because it requires you to give it a mouse event and then derives the handle from that event. I already have the handle (or at least, its ID) and just want to check if the connection I'm about to make is valid, according to the handle props I've already passed to<Handle />
.Beta Was this translation helpful? Give feedback.
All reactions