@@ -300,11 +300,16 @@ impl<'a> ModifyInputsContext<'a> {
300300 return None ;
301301 } ;
302302
303+ let primary_input = InputConnector :: node ( output_layer. to_node ( ) , 1 ) ;
304+ let has_upstream_input = self . network_interface . upstream_output_connector ( & primary_input, & [ ] ) . is_some ( ) ;
305+ let existing_path = Self :: locate_node_in_layer_chain ( "Path" , output_layer, self . network_interface ) . is_some ( ) ;
306+
303307 // If inserting a 'Path' node, insert a 'Flatten Path' node if the type is `Graphic`.
304308 // TODO: Allow the 'Path' node to operate on table data by utilizing the reference (index or ID?) for each row.
305309 if node_definition. identifier == "Path" {
306310 let layer_input_type = self . network_interface . input_type ( & InputConnector :: node ( output_layer. to_node ( ) , 1 ) , & [ ] ) ;
307- if layer_input_type. compiled_nested_type ( ) == Some ( & concrete ! ( Table <Graphic >) ) {
311+ let requires_flatten = layer_input_type. compiled_nested_type ( ) == Some ( & concrete ! ( Table <Graphic >) ) && ( has_upstream_input || existing_path) ;
312+ if requires_flatten {
308313 let Some ( flatten_path_definition) = resolve_document_node_type ( "Flatten Path" ) else {
309314 log:: error!( "Flatten Path does not exist in ModifyInputsContext::existing_node_id" ) ;
310315 return None ;
@@ -317,6 +322,10 @@ impl<'a> ModifyInputsContext<'a> {
317322 let node_id = NodeId :: new ( ) ;
318323 self . network_interface . insert_node ( node_id, node_definition. default_node_template ( ) , & [ ] ) ;
319324 self . network_interface . move_node_to_chain_start ( & node_id, output_layer, & [ ] ) ;
325+
326+ if node_definition. identifier == "Path" && !existing_path {
327+ self . existing_node_id ( "Stroke" , true ) ;
328+ }
320329 Some ( node_id)
321330 }
322331
0 commit comments