Expected behaviour for nested category toolbox

37 views
Skip to first unread message

Gabriel

unread,
Sep 29, 2025, 11:56:28 AM (4 days ago) Sep 29
to Blockly
I added a nested category to my Blockly toolbox and want to confirm the expected behavior.

Right now, when I drag a block from the main category, the category collapses (same as with normal categories). But to reopen it, I need to double-click.

Is this the intended behavior, or should the subcategories also close so the main category can be reopened with a single click?
screenrecording-2025-09-29_11-39-15.mp4

Ronald Bourret (xWF)

unread,
Sep 29, 2025, 1:36:16 PM (4 days ago) Sep 29
to blo...@googlegroups.com
Hi, Gabriel,

This is expected behavior.

To clarify what is happening:

1) You click on the Arduino category. This opens the category (which displays Arguino's subcategories) and opens the flyout (which displays the blocks in the Arduino category).

2) You drag a block from the Arduino category to the workspace. The flyout is automatically closed (hiding the blocks in the Arduino category) but the category remains open.

3) You click on the Arduino category. Because the category is open, the click closes the category.

4) You click on the Arduino category again. Because the category is closed, the click opens the category and its flyout.

The problem is that there seem to be two reasonable actions to take when you click on an open category that has nested subcategories: close the category or open/close its flyout. Blockly can only take a single action so, by design, it closes the category. If it instead opened/closed the flyout, there would be no way to close the category.

There are three things you can do:

1) Live with the current behavior.

2) Move the blocks from the Arduino category to a subcategory. When you drag a block from a subcategory to the workspace, it closes the flyout, but continues to display the subcategory. When you click on the subcategory, it opens the flyout for the subcategory, which is the behavior you want.

3) After injecting the workspace, call `workspace.getToolbox().getFlyout().setAutoClose(false)`. This will leave the flyout open after dragging a block to the workspace. Note, however, that this behavior applies to the flyouts and you have to click the category to close it. This might not be what you want.

Ronald Bourret
Technical Writer (Provided by Synergis)


--
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 visit https://groups.google.com/d/msgid/blockly/d52fd13d-8763-46a6-8e3b-85b6ac872d57n%40googlegroups.com.

Ronald Bourret (xWF)

unread,
Sep 29, 2025, 1:38:10 PM (4 days ago) Sep 29
to blo...@googlegroups.com
"applies to the flyouts" => "applies to all flyouts"

Ronald Bourret
Technical Writer (Provided by Synergis)

Maribeth Moffatt

unread,
Sep 29, 2025, 1:41:49 PM (4 days ago) Sep 29
to Blockly
I think this is a reasonable feature request if not a bug, would you mind filing an issue on GitHub with reproduction steps / sample code?

For a nested category that *doesn't* contain blocks, it makes sense for the category to stay un-collapsed, as it would be a bit annoying to have to click back into the parent category every time, essentially adding an extra click before the flyout opens. But if the parent category contains blocks, it makes more sense to collapse it so that it only takes one click to open the flyout. So compare your video to the nested categories in the test toolbox here. In the test toolbox, it makes more sense for the parent category to stay un-collapsed as there's no flyout that opens/closes when you click it. But if there is a flyout as in your example, I think it would be reasonable to collapse the parent category at the same time you close the flyout.

Maribeth

Gabriel

unread,
Sep 29, 2025, 1:56:22 PM (4 days ago) Sep 29
to Blockly
Thank you both for the quick responses. I’ll put together a minimal reproduction and open an issue.

Best regards,
Gabriel
Reply all
Reply to author
Forward
0 new messages