Skip to content

Commit afcb85e

Browse files
committed
Modified mrc_component updateBlock_ function to call workspaces.getModuleTypeForWorkspace
instead of trying to get the corresponding editor. If the block is in a headless workspace, there is no corresponding editor.
1 parent a820f3d commit afcb85e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/blocks/mrc_component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { MRC_STYLE_COMPONENTS } from '../themes/styles'
2626
import { createFieldNonEditableText } from '../fields/FieldNonEditableText';
2727
import { Editor } from '../editor/editor';
2828
import { ExtendedPythonGenerator } from '../editor/extended_python_generator';
29+
import { getModuleTypeForWorkspace } from './utils/workspaces';
2930
import { getAllowedTypesForSetCheck, getClassData, getSubclassNames } from './utils/python';
3031
import * as toolboxItems from '../toolbox/items';
3132
import * as storageModule from '../storage/module';
@@ -142,8 +143,8 @@ const COMPONENT = {
142143
* Update the block to reflect the newly loaded extra state.
143144
*/
144145
updateBlock_: function (this: ComponentBlock): void {
145-
const editor = Editor.getEditorForBlocklyWorkspace(this.workspace, true /* returnCurrentIfNotFound */);
146-
if (editor && editor.getModuleType() === storageModule.ModuleType.ROBOT) {
146+
const moduleType = getModuleTypeForWorkspace(this.workspace);
147+
if (moduleType === storageModule.ModuleType.ROBOT) {
147148
// Add input sockets for the arguments.
148149
for (let i = 0; i < this.mrcArgs.length; i++) {
149150
const input = this.appendValueInput('ARG' + i)

0 commit comments

Comments
 (0)