Skip to content

Commit

Permalink
Fix widget extraction for chooser in StructBlock/StreamBlock in `…
Browse files Browse the repository at this point in the history
…ListBlock`
  • Loading branch information
zerolab committed Oct 12, 2022
1 parent 2ff0089 commit 389ba8f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion wagtail_localize/views/edit_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ def widget_from_block(block, content_components=None):
return widget_from_block(
block.child_blocks.get(block_field_name), content_components
)
elif isinstance(block, blocks.ListBlock):
elif isinstance(block, blocks.ListBlock) and content_components is not None:
return widget_from_block(block.child_block, content_components[1:])

return {"type": "unknown"}
Expand All @@ -513,6 +513,17 @@ def widget_from_block(block, content_components=None):
block_field_name = field_path_components[2]
block_field = block_type.child_blocks[block_field_name].label
content_components = field_path_components[2:]
elif isinstance(block_type, blocks.ListBlock):
block_field = None
content_components = None
if isinstance(
block_type.child_block, (blocks.StructBlock, blocks.StreamBlock)
):
block_field_name = field_path_components[3]
block_field = block_type.child_block.child_blocks[
block_field_name
].label
content_components = field_path_components[2:]
else:
block_field = None
content_components = None
Expand Down

0 comments on commit 389ba8f

Please sign in to comment.