[lexical] Fix: merge TextNodes when __state contains different number of default values#8273
Merged
etrepum merged 1 commit intofacebook:mainfrom Apr 1, 2026
Merged
Conversation
… of default values
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
approved these changes
Apr 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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__statedefined, yet have a different number of state configs, then even if all the values are equal (accounting for defaults), thennodeStatesAreEquivalentwould 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.