Skip to content

[lexical-website] Documentation Update: clarify Yjs custom node property syncing#8288

Merged
etrepum merged 1 commit intofacebook:mainfrom
Vedthakar:issue-7280
Apr 7, 2026
Merged

[lexical-website] Documentation Update: clarify Yjs custom node property syncing#8288
etrepum merged 1 commit intofacebook:mainfrom
Vedthakar:issue-7280

Conversation

@Vedthakar
Copy link
Copy Markdown
Contributor

@Vedthakar Vedthakar commented Apr 6, 2026

Description

Closes #7280

This PR documents an important constraint of Lexical collaboration with Yjs: custom node properties are only reliably synced when they are own enumerable properties of the node.

To make that behavior clear for consumers implementing custom nodes without NodeState, the docs now explain that node properties should be explicitly initialized in the constructor, even when the intended initial value is undefined. This avoids cases where optional properties are not present as own enumerable fields and therefore are not reliably synced during collaboration.

The documentation also points readers toward NodeState as the preferred approach, since it avoids this class-property syncing pitfall and has better built-in support for collaboration use cases.

What changed

  • added/updated documentation describing how Yjs syncs custom node properties
  • clarified that properties should be initialized in the constructor if a node relies on instance properties instead of NodeState
  • reinforced the recommendation to use NodeState where possible

Why

Without this note, it is easy for consumers to define optional node properties using class field syntax and assume they will participate in collab syncing automatically. In practice, this can lead to confusing behavior because only own enumerable properties are reliably synchronized.

This PR makes that constraint explicit so custom node implementations are less likely to break in collaborative editors.

Test plan

Before

The relevant behavior existed, but it was easy to miss or misunderstand when implementing custom nodes for collaborative editing.

After

  • verified the documentation now clearly describes the Yjs syncing constraint
  • verified the guidance points developers toward explicit constructor initialization or NodeState

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 6, 2026
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview, Comment Apr 7, 2026 0:11am
lexical-playground Ready Ready Preview, Comment Apr 7, 2026 0:11am

Request Review

@etrepum etrepum changed the title Doc: Add note about yjs property syncing [lexical-website] Documentation Update: clarify Yjs custom node property syncing Apr 6, 2026
Comment on lines +252 to +257
const repro = new URLSearchParams(window.location.search).get('repro');

if (repro === '4493') {
return <Issue4493Repro />;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a good way to do this, would be better to handle it as a separate page entirely (you can see how pages are configured in vite.config.ts) or even to create a new package specifically for self-contained e2e tests.

There's also nothing that actually invokes this repro (I would expect it to be the subject of an e2e test), and it's related to a completely separate issue so it certainly doesn't belong in this PR.

@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Apr 7, 2026
@etrepum etrepum added this pull request to the merge queue Apr 7, 2026
Merged via the queue into facebook:main with commit a4f3c31 Apr 7, 2026
36 checks passed
@etrepum etrepum mentioned this pull request Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Documentation: Add note about yjs property syncing

2 participants