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)