Injected Blockly Workspace Occasionally not Appearing

437 views
Skip to first unread message

Laurie Gale

unread,
Apr 7, 2021, 6:07:05 AM4/7/21
to Blockly
I have a blockly toolbox/workspace that controls a game (all contained within a web app) which works fine. However, sometimes when the web app loads up, the original blockly workspace that is meant to load does not display. The code is still present/working as it still successfully powers the game and generates the correct JS but it just doesn't get displayed.

This only happens occasionally but is quite an annoying bug, what could be causing this? I tried making the position central and removed scroll boxes but these haven't helped?

Also, for the purposes of the game, the blockly workspace(s) are originally blocked using Jquery so the player cannot edit the blocks to start off with.

Thanks!

Beka Westberg

unread,
Apr 7, 2021, 5:45:52 PM4/7/21
to blo...@googlegroups.com
Hello,

> Also, for the purposes of the game, the blockly workspace(s) are originally blocked using Jquery so the player cannot edit the blocks to start off with.

This is most likely what is causing your problem :/ Blockly can be buggy on occasion, but the injection is pretty solid! If you post the code you're using the block/unblock the workspace, or any fancy css you might be using, someone here might be able to give advice.

Sorry I can't be more help :/

Best,
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/f09ceb72-c105-446a-8d5c-4ded40e1fa4fn%40googlegroups.com.

Laurie Gale

unread,
Apr 18, 2021, 11:33:45 AM4/18/21
to Blockly
I have different blockly workspaces the user can switch between, so when a button is clicked it would set the display of two of the blockly workspaces to none and the other to block.

Here's the code for the block UI that prevents the user from changing the blockly workspace
          Ok: function() {
            $( this ).dialog( "close" );
            if (blockWorkspace) {
              $('div.blockly-editor').block({
                message: null, 
                overlayCSS:{backgroundColor:'#ffffff', fontFamily:'Racing Sans One'}
              });
            }
          }

Here's the CSS for the blockly toolboxes:


      var options = { 
        toolbox : toolbox, collapse : true, comments : false, disable : true, maxBlocks : 50, trashcan : false, horizontalLayout : true, toolboxPosition : 'start', css : true, media : 'https://blockly-demo.appspot.com/static/media/', rtl : false, scrollbars : false, sounds : true, oneBasedIndex : true
      };    

This loss of the blocks being displayed tends to happen if the browser window is moved/repositioned

Abby Schmiedt

unread,
Apr 23, 2021, 7:45:22 PM4/23/21
to Blockly
Hello!

I just want to clarify, is the workspace still visible and just the blocks are not? Or is the entire workspace not visible? 

Some debugging to try: 
  • If this is happening when the window is resized then you can try to set a break point in the workspace resize method. 
  • If you see a workspace, but not blocks you might want to check that you are loading your blocks properly.
  • Check to see if the blockly div you are injecting into has a div with an "injectionDiv" class underneath it. If it does, this means inject worked properly and there is probably some other CSS that is causes the problem. 
Cheers,
Abby
Reply all
Reply to author
Forward
0 new messages