Using functions with plusminus plugin gives error for blockly-react

110 views
Skip to first unread message

rajuga...@gmail.com

unread,
Oct 14, 2020, 2:24:15 AM10/14/20
to Blockly
You will add a <Block type="procedures_defnoreturn" /> in the blockly-react sample inside App.js and then try to drag the block in the workspace,  after dragging right click on procedure block it will give you an error : "TypeError: a.getId is not a function"Screenshot from 2020-10-14 11-48-11.png

When i use acorn interpreter on top of the blockly, and then as soon as i try to drag the "procedure" block , it throws an error saying : "TypeError: Cannot read property 'length' of undefined".  To remove error in this case, i just have to comment out the code generation line.

generateCodeAndLoadIntoInterpreter = (ws) => {
// Generate JavaScript code and parse it.
Blockly.JavaScript.STATEMENT_PREFIX = "highlightBlock(%1);\n";
Blockly.JavaScript.addReservedWords("highlightBlock");
let latestCode = Blockly.JavaScript.workspaceToCode(ws); // remove this line with a string

this.resetStepUi(ws);
return latestCode;
};

Screenshot from 2020-10-14 11-53-58.png

rajuga...@gmail.com

unread,
Oct 14, 2020, 2:25:50 AM10/14/20
to Blockly
I think there is an error in plusminus for procedure.js itself in the package

rajuga...@gmail.com

unread,
Oct 14, 2020, 2:26:55 AM10/14/20
to Blockly
this error is not happening in procedures  if i remove the "plus-minus" package. Can you check, guys ?

Beka Westberg

unread,
Oct 14, 2020, 9:55:30 AM10/14/20
to blo...@googlegroups.com
Hello,

Thanks for reporting this! The first error you've reported should be an easy fix. It looks like I just forgot some brackets here.

For the second one, I'm not sure what the problem is. I'll have to do some more investigating. But I should definitely have a fix for the first error up today!

Thank you again for reporting :D
--Beka

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/4036c063-14f4-495c-bc46-e1d40f4183a5n%40googlegroups.com.

rajuga...@gmail.com

unread,
Oct 15, 2020, 12:19:08 AM10/15/20
to Blockly
Hey, equal amount of bracket is there in "for loop" , I wonder what brackets you are talking about 

Beka Westberg

unread,
Oct 15, 2020, 9:36:01 AM10/15/20
to blo...@googlegroups.com
Before it looked like this:

for (let i = 0, model; (model = varModels); i++) { ... }

But what it should have looked like is this:

for (let i = 0, model; (model = varModels[i]); i++) { ... }

It's a subtle thing, but it really changes the behavior of the loop!

What I decided to do was just switch it over to for...of syntax. You can see the PR here (I cleaned up some other stuff as well). I'll look into the code generation stuff more today =)

Best!
Beka

rajuga...@gmail.com

unread,
Oct 16, 2020, 2:27:49 AM10/16/20
to Blockly
Great then that solves second error too, i tried it. 
But there is a new thing i found -  "if you have only a flyout and then you try to click on '+' sign, it will mutate it on the flyout too, messsing things up"

Beka Westberg

unread,
Oct 16, 2020, 5:27:01 PM10/16/20
to blo...@googlegroups.com
Hello,

Here's an update on what I've done so far.
  • Created a PR fixing the context menu bug.
  • Created another PR fixing a bug related to conflicting parameter names.
  • Put up an issue about your code generation bug.
Great then that solves second error too, i tried it. 

Hmm I think that might just be because you're now using a non-minified blockly. I think the error is caused by the fact that minified blockly doesn't call getVars(), but non-minified blockly does (as described here).

But there is a new thing i found -  "if you have only a flyout and then you try to click on '+' sign, it will mutate it on the flyout too, messsing things up"

Oh yikes, that's no good. But it should be a pretty easy fix! I'll definitely take a look.

Thank you again for reporting these bugs! I really appreciate it :D
--Beka 

bekawe...@gmail.com

unread,
Oct 16, 2020, 6:25:35 PM10/16/20
to Blockly
I started looking into the in-flyout mutations issue you mentioned, but I can't get it to reproduce :/

Here's a gif of what happens when I try to reproduce it:
ProceduresGif.gif
As you can see the blocks just get added to the workspace.

Are you perhaps using a simple toolbox (like the below) rather than one with categories? Could you provide a gif/video of what you're seeing?
SimpleToolbox.png

Thank you again for your help!
--Beka

rajuga...@gmail.com

unread,
Oct 16, 2020, 11:12:13 PM10/16/20
to Blockly
Screenshot from 2020-10-17 08-41-26.png

rajuga...@gmail.com

unread,
Oct 16, 2020, 11:31:25 PM10/16/20
to Blockly
Just a simple flyout

rajuga...@gmail.com

unread,
Oct 16, 2020, 11:35:17 PM10/16/20
to Blockly
Thankyou so much .:)

Beka Westberg

unread,
Oct 17, 2020, 3:27:52 PM10/17/20
to blo...@googlegroups.com
Ok blocks mutating while in the flyout should be removed by this new PR =)

But I will warn you, you might run into problems using procedures in a simple toolbox. Usually applications use a category toolbox so that they can add all of the 'call' blocks to the flyout programmatically using a dynamic category.

It should definitely be possible to get it working with your setup! But it may require a bit of extra work.

Either way, that was definitely something I wanted to get fixed :D Thank you for providing the screenshot of what you were seeing! That really helped me reproduce the issue =)

Best wishes,
Beka

Reply all
Reply to author
Forward
0 new messages