Skip to content

Table block: CRDT initialization replaces cell content with empty objects #76555

@lancewillett

Description

@lancewillett

Description

When Real-Time Collaboration (RTC) is enabled, table block cell content renders blank in the editor. The CRDT document initialization replaces RichText cell content (strings) with empty {} objects in the block attributes, while originalContent and post_content remain intact.

Preview and front-end rendering are unaffected — only the editor view is broken.

Steps to reproduce

  1. Create a post with a core/table block containing data in header and body cells
  2. Enable Real-Time Collaboration (RTC) with the HTTP polling provider
  3. Save the post
  4. Reload the editor

Expected: Table cells show their content
Actual: All table cells render blank (empty textboxes)

Technical analysis

Performed via browser DevTools on a live WordPress.com P2 site running Gutenberg 22.7.0:

Block attributes are corrupted

// Every cell's content is an empty plain object:
tableBlock.attributes.head[0].cells[0].content
// → {} (Object with zero keys, not a RichTextData instance)

tableBlock.attributes.body[0].cells[0].content
// → {} (same)

Normal (non-RTC) table cells store content as strings ("Product", "<a href='...'>Link</a>"). With RTC enabled, the CRDT initialization replaces these with empty {} objects.

originalContent is intact

tableBlock.originalContent
// → '<figure class="wp-block-table"><table><thead><tr><th>Product</th>...'
// All cell data present and correct

Serialization vs rendering divergence

  • getEditedPostContent() returns correct HTML with all table data (serializes from originalContent)
  • React renders from block attributes (head/body arrays) → blank cells
  • isValid: true because validation checks against originalContent, not attributes

The corruption happens at CRDT init time

Even after deleting _crdt_document post meta, the bug reproduces on the very next page load. The CRDT system creates a new document from the parsed blocks, and during that initialization, table cell RichText content is not properly captured.

The issue is specifically with how the CRDT document handles RichText attribute sources (source: 'html') stored as block attributes in the table block. Table cells use source: 'html' attributes (unlike paragraph/heading blocks which use source: 'rich-text' on innerHTML). The CRDT initializer appears to not handle this attribute type correctly.

Workaround

Re-parsing the block from originalContent and updating attributes in the store restores the data:

const reparsed = wp.blocks.parse('<!-- wp:table ... -->' + tableBlock.originalContent + '<!-- /wp:table -->');
wp.data.dispatch('core/block-editor').updateBlockAttributes(tableBlock.clientId, {
  head: reparsed[0].attributes.head,
  body: reparsed[0].attributes.body,
});

This is a temporary in-memory fix — the CRDT re-corrupts on next page load.

Environment

  • WordPress.com (Simple sites)
  • Gutenberg 22.7.0
  • RTC provider: HTTP polling
  • Affects: core/table block (likely any block using source: 'html' RichText attributes)

Related

  • Reported by multiple users across different WordPress.com P2 sites
  • Bug persists after Gutenberg 22.7.0 update (which fixed other RTC/polling issues)

Metadata

Metadata

Assignees

Labels

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions