Skip to content

[lexical] Fix: merge TextNodes when __state contains different number of default values#8273

Merged
etrepum merged 1 commit intofacebook:mainfrom
james-atticus:node-state-null
Apr 1, 2026
Merged

[lexical] Fix: merge TextNodes when __state contains different number of default values#8273
etrepum merged 1 commit intofacebook:mainfrom
james-atticus:node-state-null

Conversation

@james-atticus
Copy link
Copy Markdown
Contributor

Description

When node state is defined for a given node, if the state values are all default, then that's considered equivalent to a node with __state: undefined. However if you have two nodes that both have __state defined, yet have a different number of state configs, then even if all the values are equal (accounting for defaults), then nodeStatesAreEquivalent would return false and the nodes would not be merged.

I'm not sure if this causes any issues in practice. I only noticed it because we have a sanity-check plugin to ensure that the main editor state stays in sync with an editor state that's reconstructed from Yjs. For Collab V2, because text nodes are stored in a single YText, the reconstructed editor state had merged text nodes, because we check for default state values in the sync code. Haven't thought about the potential impact on Collab V1.

Test plan

Unit test fails before, passes after the change.

@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 1, 2026
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 1, 2026

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

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

Request Review

@etrepum etrepum added this pull request to the merge queue Apr 1, 2026
Merged via the queue into facebook:main with commit dea864b Apr 1, 2026
38 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants