Skip to content

Commit 40acf7b

Browse files
committed
BlockCategoryDisplay: Refresh Block context when reusing
In the category display, blocks reused when switching the current BlockCode node. When that happens, the BlockExtension needs to have its context update so that it can provide options for the current BlockCode node. https://phabricator.endlessm.com/T35647
1 parent 6a05c62 commit 40acf7b

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

addons/block_code/ui/blocks/block/block.gd

+6
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ func get_parameter_values() -> Dictionary:
8888
return template_editor.get_parameter_values()
8989

9090

91+
## Use the current BlockEditorContext components
92+
func refresh_context():
93+
if _context and _block_extension:
94+
_block_extension.context_node = _context.parent_node
95+
96+
9197
func _update_template_editor():
9298
if template_editor == null:
9399
return

addons/block_code/ui/picker/categories/block_category_display.gd

+4
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,9 @@ func _get_or_create_block(block_definition: BlockDefinition) -> Block:
7070
block.drag_started.connect(func(block: Block): block_picked.emit(block))
7171
_blocks_container.add_child(block)
7272
_blocks[block_definition.name] = block
73+
else:
74+
# If the block is being reused, make sure the context corresponds to
75+
# the current BlockCode node.
76+
block.refresh_context()
7377

7478
return block

0 commit comments

Comments
 (0)