Skip to content

Plate editor occasionally drops unknown (adapted Plone block) nodes on save #125

Description

@nils-pzr

Problem: Adapted Plone block nodes can be dropped on save

Problem

Classic/adapted Plone blocks, for example teaser, are stored in the somersault value as Plate nodes with:

{
  "type": "unknown"
}

These nodes carry the original block data, for example:

{
  "@type": "teaser",
  "href": "...",
  "preview_image": "..."
}

They are rendered through:

plone-block-adapter-renderer.tsx

When a document containing such a node is loaded into the blocks editor and saved, the unknown node is sometimes silently dropped from the saved blocks.__somersault__.value — even when the block was not touched at all.

Warning

This is flaky: in repeated identical save cycles, the node survived in one run and was gone in another.

Steps to reproduce

  1. Create a Document whose somersault value contains an adapted block node:
{
  "type": "unknown",
  "@type": "teaser",
  "id": "abc123",
  "children": [
    {
      "text": ""
    }
  ]
}
  1. Open the document in the blocks editor via @@edit.

    This is also reproducible via @@translate from #23.

  2. Save without modifying the block.

  3. Inspect blocks.__somersault__.value on the saved content.

Expected behavior

The unknown node is preserved.

The adapter renders it, and the data round-trips untouched.

Actual behavior

The node is intermittently missing from the saved value.

This results in silent data loss of the adapted block.

Suspected cause

Editor normalization may remove node types it does not recognize, possibly racing with lazily loaded editor plugins.

Hypothesis:

If the adapter/plugin for the node type is not registered yet when normalization runs, the node may be treated as invalid and removed.

Impact

Silent data loss for any adapted Plone block when a page is opened and saved in the blocks editor.

This affects the regular @@edit flow, not only @@translate.

Context

Observed while implementing and testing the @@translate route in #23.

This was not introduced by that work. It is reproducible with the plain editor flow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions