Hiding toolbox results in trapped blocks

77 views
Skip to first unread message

Jing An Tew

unread,
Nov 5, 2025, 3:05:04 AMNov 5
to Blockly
Hi, when hiding the toolbox programmatically through `.getToolbox().setVisible(false);`, the starting block gets trapped (it can't be dragged past the red line), this behavior disappears 
after blocks are added to the starting block, anyone know why this is the case?
Toolbox Shown

Block cannot be dragged past this invisible red line
Screenshot 2025-11-05 160326.png
When blocks are attached, no issue dragging them past the toolbox, removing that block brings the issue back.

Jing An Tew

unread,
Nov 5, 2025, 3:09:58 AMNov 5
to Blockly
Screenshot 2025-11-05 143620.png
Toolbox Shown

Screenshot 2025-11-05 143702.png
Invisible Red line blocking it from being dragged into the hidden toolbox space

Taurus Rico

unread,
Nov 5, 2025, 9:02:47 AMNov 5
to Blockly
Hi, I think the workspace is not used to it's new dimensions.
Whenever you set the Toolbox to invisible and also visible you can call Blockly.svgResize(workspace); 
Then the workspace calculates it's new dimensions to fill the container space completely.

Greetings, Rico

Jing An Tew

unread,
Nov 5, 2025, 10:29:55 AMNov 5
to Blockly
Hi Rico,
Thanks a lot, that seems to have solved the issue. 

Jing An Tew

unread,
Nov 10, 2025, 5:37:04 AMNov 10
to Blockly
Hi, an additional question, since showing the toolbox cuts space off the blockly workspace, and hiding it increases the size of the blockly workspace, to give a better user experience, is there a method to call to ensure the blocks remain (visually) at the same position?
Message has been deleted

Jing An Tew

unread,
Nov 10, 2025, 6:02:58 AMNov 10
to Blockly
I should mention I'm currently trialing scrolling the workspace based off the toolbox width, but it doesn't seem to be working 
Code used when hiding toolbox: `blocklyWorkspace.scroll(blocklyWorkspace.scrollX + <lengthOfToolboxWidth>, 0);`

For some context on what's happening, I have attached a video here, I'm not sure why the scrollX value is changing even though the workspace has not been interacted with in any way.
2025-11-10 18-58-52.mp4

Taurus Rico

unread,
Nov 12, 2025, 7:02:48 AMNov 12
to Blockly
Hello,
I don't have a solution for your scrolling function but I think it could work if you experiment a bit.
I have my own Toolbox on the right side of the screen with toolboxPosition: 'end' in the blockly inject options. There the effect doesn't happen.
So if you don't care if it's left or right, you can also place it to the right as a workaround. 

Greetings, Rico

Jing An Tew

unread,
Nov 13, 2025, 9:23:50 AM (14 days ago) Nov 13
to Blockly
Hi Rico, thanks for the response. Unfortunately, my toolbox needs to be on the left. Guess it's back to the drawing board. I do find it quite weird that this is happening though. The existing code should work fine.
Reply all
Reply to author
Forward
0 new messages