-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lexical-mark] Bug Fix: Stop MarkNode __ids array deep copy in clone #6810
Conversation
… addId and deleteId functions
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, @etrepum to have a look as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, maybe a little more defensive than it needs to be, although this maintains type compatibility externally. The $isMarkNode(self)
checks are useless if you wanted to simplify further, I can only imagine they are there from a time when this.getLatest()
and this.getWritable()
had the wrong types?
Description
In this PR creation of a new
__ids
array is avoided in the clone function of the MarkNode, and the cloned MarkNode will have the same reference to__ids
array of the original node. This has made an issue in thesyncPropertiesFromYjs
function where we compare the old and new nodes' properties, and only make an update to ydoc if the properties are changed. In the case MarkNodes, because the clone function deep-copies the__ids
array the property comparison detects a change, despite the arrays being identical.The fix is keeping the same
__ids
array in the cloned node, and only creating new__ids
array when the array is modified.