diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 00693230b9..4bbbd9aeec 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -9,6 +9,7 @@ Changelog * Fix: Status button on 'edit page' now links to the correct URL when live and draft slug differ (LB (Ben Johnston)) * Fix: Image title text in the gallery and in the chooser now wraps for long filenames (LB (Ben Johnston), Luiz Boaretto) * Fix: Move image editor action buttons to the bottom of the form on mobile (Julian Gallo) + * Fix: StreamField icons are now correctly sorted into groups on the 'append' menu (Tim Heap) 2.0 (xx.xx.xxxx) - IN DEVELOPMENT diff --git a/docs/releases/2.1.rst b/docs/releases/2.1.rst index a9cfa61c39..4936c5cf72 100644 --- a/docs/releases/2.1.rst +++ b/docs/releases/2.1.rst @@ -22,7 +22,8 @@ Bug fixes * Status button on 'edit page' now links to the correct URL when live and draft slug differ (LB (Ben Johnston)) * Image title text in the gallery and in the chooser now wraps for long filenames (LB (Ben Johnston), Luiz Boaretto) - * Fix: Move image editor action buttons to the bottom of the form on mobile (Julian Gallo) + * Move image editor action buttons to the bottom of the form on mobile (Julian Gallo) + * StreamField icons are now correctly sorted into groups on the 'append' menu (Tim Heap) Upgrade considerations ====================== diff --git a/wagtail/core/blocks/stream_block.py b/wagtail/core/blocks/stream_block.py index 5618646499..12838f9bb9 100644 --- a/wagtail/core/blocks/stream_block.py +++ b/wagtail/core/blocks/stream_block.py @@ -56,6 +56,11 @@ class BaseStreamBlock(Block): """ return StreamValue(self, self.meta.default) + def sorted_child_blocks(self): + """Child blocks, sorted in to their groups.""" + return sorted(self.child_blocks.values(), + key=lambda child_block: child_block.meta.group) + def render_list_member(self, block_type_name, value, prefix, index, errors=None, id=None): """ Render the HTML for a single list item. This consists of an
  • wrapper, hidden fields @@ -64,7 +69,7 @@ class BaseStreamBlock(Block): child_block = self.child_blocks[block_type_name] child = child_block.bind(value, prefix="%s-value" % prefix, errors=errors) return render_to_string('wagtailadmin/block_forms/stream_member.html', { - 'child_blocks': self.child_blocks.values(), + 'child_blocks': self.sorted_child_blocks(), 'block_type_name': block_type_name, 'prefix': prefix, 'child': child, @@ -138,7 +143,7 @@ class BaseStreamBlock(Block): return render_to_string('wagtailadmin/block_forms/stream.html', { 'prefix': prefix, 'list_members_html': list_members_html, - 'child_blocks': sorted(self.child_blocks.values(), key=lambda child_block: child_block.meta.group), + 'child_blocks': self.sorted_child_blocks(), 'header_menu_prefix': '%s-before' % prefix, 'block_errors': error_dict.get(NON_FIELD_ERRORS), })