bartbutenaers / node-red-contrib-blockly

A Node Red node for visual programming a function using Blockly
Apache License 2.0
88 stars 22 forks source link

Setting outputs to 0 #125

Open cymplecy opened 9 months ago

cymplecy commented 9 months ago

The number of outputs spinner doesn't let me select 0 outputs but I can type it in manually

But, if I do that and deploy then the block become un-editable and the interface locks up on me!

I was only wanting to do this to make a node look nicer so in future, I won't do it :)

But just mentioning it in case there's a quick fix

bartbutenaers commented 9 months ago

Spinner minimum 1

Allowing the spinner to go down to 0 should be rather easy to change. Please try to change the minimum to 0 in this statement. I have not tried it yet!

Unresponsive user interface

Not sure how to solve this...

Here a bit of detailed explanation of how you can analyze something like this:

  1. I manually enter 0 in the "output" input field:

    image

  2. I press the fullscreen button.

  3. Then I see this error in my browser console window:

    image

  4. In the callstack you see that the error occurs in one of our js files, so click on that link to navigate to our related code.

  5. Add a breakpoint to that statement.

  6. Refresh the flow editor browser window, and repeat these steps again.

  7. The debugger will halt a number of times on your breakpoint, but that is of no interest of us because it will only go wrong after we have changed the number of outputs.

  8. Change the number of ouputs again to 0, and expand the workspace.

  9. Now the debugger will halt again on your breakpoint, and you will see that the error occurs in a function that we use to dynamically fill a blockly dropdown:

    image

  10. Since the number of outputs is 0, the options variable will contain an empty array.

  11. Further on Blockly crashes on that and gives the error "FieldDropdown options must not be an empty array". So blockly doesn't want to show an empty dropdown, which makes sense...

It is about the dropdown where we show the output numbers:

image

When we have no outputs, this block in fact has no sense. But not sure how to handle that, in a non-confusing way for the user.

But of course your request makes sense...

bartbutenaers commented 8 months ago

@cymplecy, Any suggestions? Otherwise I need to ask on the Blockly forum whether they have any tips...

cymplecy commented 8 months ago

Sorry for delay in replying Changing min:0 works but as soon as I try and add blocks - goes wrong

I've not come up with any sensible ideas (we can't default outputs to 0) on how to deal with 0 without a lot of if else :(

I think, as its purely a visual issue that doesn't really matter that just best to not allow manual editing of that field and live with it