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

bug?: misnamed dynamic input port #247

Open
FramnkRulez opened this issue Dec 17, 2024 · 0 comments
Open

bug?: misnamed dynamic input port #247

FramnkRulez opened this issue Dec 17, 2024 · 0 comments

Comments

@FramnkRulez
Copy link

FramnkRulez commented Dec 17, 2024

I'm trying a logical AND node type that dynamically renders the inputs so that it always creates an extra input after the last connected input:

.addNodeType({
    type: "and",
    label: "And Boolean Test",
    description: "Performs a logical AND operation on the input boolean values",
    initialWidth: 140,
    inputs: ports => (inputData, connections) => {
      // Determine the number of current connections
      const connectedInputs = Object.keys(connections.inputs).length;
  
      // Create an array of boolean inputs, adding one extra unconnected input
      const inputPorts = [];
      for (let i = 0; i < connectedInputs; i++) {
        console.log(`input_${i + 1}`);
        inputPorts.push(
          ports.boolean({ name: `input_${i + 1}`, label: `Input ${i + 1}` })
        );
      }
      return inputPorts;
    },
    outputs: ports => [
      ports.boolean()
    ]
  })

This works as expected, the only issue is that when I render the nodes to JSON it doesn't seem to name the first input input_1 as expected (instead it's named boolean):

   "4CnGWCxuXc":{
      "id":"4CnGWCxuXc",
      "x":277.20001220703125,
      "y":77.39990234375,
      "type":"and",
      "width":140,
      "connections":{
         "inputs":{
            "boolean":[
               {
                  "nodeId":"2b3X8ISyEe",
                  "portName":"boolean"
               }
            ],
            "input_2":[
               {
                  "nodeId":"Sf7YdDLyS6",
                  "portName":"boolean"
               }
            ],
            "input_3":[
               {
                  "nodeId":"vMfnsOGUwS",
                  "portName":"boolean"
               }
            ],
            "input_1":[
               {
                  "nodeId":"2b3X8ISyEe",
                  "portName":"boolean"
               }
            ],
            "input_4":[
               {
                  "nodeId":"FIYlnukifV",
                  "portName":"boolean"
               }
            ]
         },
         "outputs":{
            
         }
      },
      "inputData":{
         "input_1":{
            "boolean":false
         },
         "input_2":{
            "boolean":false
         },
         "input_3":{
            "boolean":false
         },
         "input_4":{
            "boolean":false
         },
         "input_5":{
            "boolean":false
         }
      }
   }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant