Skip to content

deleteBlock helper doesn't handle the case where the layout is empty after a delete but there are already existing blocks #6752

Open
@JeffersonBledsoe

Description

@JeffersonBledsoe

Describe the bug

The deleteBlocks helper function has a functionality where if the blocks_layout key is empty after deletion, it will create a new block with the

if (newFormData[blocksLayoutFieldname].items.length === 0) {
newFormData = addBlock(
newFormData,
config.settings.defaultBlockType,
0,
{},
intl,
);
}

Possible solutions

  • Leave it as is
    • Can lead to odd behaviour where you have block definitions stored that aren't used in the layout
  • Leave it as is and delete the existing block data
    • Could lead to possible removal of wanted data
  • Add all of the existing blocks back into the layout.
    • It may end up with a messy layout, but at least it becomes clear what is stored and what isn't
  • Check if any of the existing blocks are match the default block type and add that. Fallback to one of the above behaviours if not

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions