From ee6a842a6b616472634a81b1c96f8e495810159b Mon Sep 17 00:00:00 2001 From: Adam Gerhant <116332429+adamgerhant@users.noreply.github.com> Date: Wed, 16 Apr 2025 01:52:15 -0700 Subject: [PATCH] Fix dragging a node onto a secondary input's wire not working (#2583) Fix dragging onto wire --- .../node_graph/node_graph_message_handler.rs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs b/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs index 1894c444..787e8d40 100644 --- a/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs +++ b/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs @@ -1155,6 +1155,28 @@ impl<'a> MessageHandler> for NodeGrap !bezier.rectangle_intersections(bounding_box[0], bounding_box[1]).is_empty() || bezier.is_contained_within(bounding_box[0], bounding_box[1]) }) + .collect::>() + .into_iter() + .filter_map(|mut wire| { + if let Some(end_node_id) = wire.wire_end.node_id() { + let Some(actual_index_from_exposed) = (0..network_interface.number_of_inputs(&end_node_id, selection_network_path)) + .filter(|&input_index| { + network_interface + .input_from_connector(&InputConnector::Node { node_id: end_node_id, input_index }, selection_network_path) + .is_some_and(|input| input.is_exposed_to_frontend(selection_network_path.is_empty())) + }) + .nth(wire.wire_end.input_index()) + else { + log::error!("Could not get exposed input index for {:?}", wire.wire_end); + return None; + }; + wire.wire_end = InputConnector::Node { + node_id: end_node_id, + input_index: actual_index_from_exposed, + }; + } + Some(wire) + }) .collect::>(); let is_stack_wire = |wire: &FrontendNodeWire| match (wire.wire_start.node_id(), wire.wire_end.node_id(), wire.wire_end.input_index()) {