Repository navigation
RTC: Fix CRDT serialization of nested RichText attributes - #76597
Conversation
|
Size Change: -74 B (0%) Total Size: 8.75 MB
ℹ️ View Unchanged
|
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
commented
Mar 17, 2026
|
Flaky tests detected in b30374a. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23209853444
|
commented
Mar 17, 2026
|
I just cherry-picked this PR to the wp/7.0 branch to get it included in the next release: ac9073b |
What?
Closes #76555.
Fixes table block cell content syncing (and any other nested
array-type attributes with nested rich text) in real-time collaboration.Why?
The corruption happens at Yjs encode time, when the CRDT doc is synced or persisted:
RichTextDataclass instances, but deeply nested (e.g.body[].cells[].content).makeBlocksSerializableruns but only converts top-levelRichTextDatato strings. The nested instances ofRichTextDatainside the table'sbody/head/footaren't properly mapped to strings with.valueOf()and instead stay as deeply-nested objects instead of being properly converted to serializable data.RichTextDatainstances the same way it would any plain object, usingObject.keys(). SinceRichTextDatastores its data in a private field, there are no enumerable keys, so each cell's content is encoded as{}.How?
Added a
serializeAttributeValuehelper that recursively walks attribute values and converts any deeply-nestedRichTextDatainstances to their HTML string representation via.valueOf().This approach handles the table block's deeply nested structure (
body[].cells[].content) and will also cover any other blocks that storeRichTextDatainside array or object attributes.Testing Instructions
Here's the original reproduction from this comment:
Enable RTC via Settings -> Writing -> "Enable real-time collaboration" checkbox.
Create a post with a table:
As user A, load the post in one tab with RTC enabled.
As user B, load the same post in a second tab with RTC enabled.
See user A's table get cleared out.
Screen.Recording.2026-03-17.at.11.47.56.AM.mov
On this branch (
fix/crdt-table-emptying), you should no longer see the table cleared.Also see the added unit tests:
which failed before these changes.
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Used for: Identifying the root cause and implementing the fix.