-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Description
I updated blockly in a project from
1.20190419.0
to "npm": "blockly": "2.20190722.1"
In order to restore a view, I use
Blockly.Xml.domToWorkspace(this.contentData.content, this.workspace);
In our project we only have one top/root block (with childs) by design.
Some child blocks have FieldDropdown, which are filled with a function like
new Blockly.FieldDropdown(function createSelectedDataTableField_func() {
let selectedTables = [];
...
return selectedTables;
with FieldDropdown values depending on what is set in the root block.
With Blockly 1.20190419.0 => OK
But with Blockly 2.20190722.1 after domToWorkspace, I faced the following. Traces in console like:
Cannot set the dropdown's value to an unavailable option. Block type: dataset_field_table_column, Field name: FIELD_TABLE, Value: mapchartbycust
In the createSelectedDataTableField_func() call, the child block's getRootBlock() is itself O_o
And the workspace has two+ top blocks, the good one and the child(s). So If I call getRootBlock() to do a
let xyz = rootBlock.getFieldValue('SELECTED_TABLE');
call it won't work anymore.
I had to (bad) hack our code with
if(rootBlock.type == 'dataset_field_table_column') {
rootBlock = rootBlock.workspace.getTopBlocks()[0];
}
to select the "good" root block.
Later, I get the Blockly.Events.BLOCK_CREATE event, and the child(s) block(s) are (back) to root block childs => OK
Expected behavior
Like before
Desktop (please complete the following information):
- OS: Windows 10
- Browser Chrome
- Version 76.0.3809.100