Skip to content
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

Merged
merged 2 commits into from
Nov 8, 2024

Conversation

ebads67
Copy link
Collaborator

@ebads67 ebads67 commented Nov 8, 2024

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 the syncPropertiesFromYjs 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.

Copy link

vercel bot commented Nov 8, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 8, 2024 11:41am
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 8, 2024 11:41am

@facebook-github-bot facebook-github-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 Nov 8, 2024
Copy link

github-actions bot commented Nov 8, 2024

size-limit report 📦

Path Size
lexical - cjs 29.94 KB (0%)
lexical - esm 29.75 KB (0%)
@lexical/rich-text - cjs 38.56 KB (0%)
@lexical/rich-text - esm 31.64 KB (0%)
@lexical/plain-text - cjs 37.18 KB (0%)
@lexical/plain-text - esm 28.95 KB (0%)
@lexical/react - cjs 40.35 KB (0%)
@lexical/react - esm 33.07 KB (0%)

@ebads67 ebads67 marked this pull request as ready for review November 8, 2024 10:38
ivailop7
ivailop7 previously approved these changes Nov 8, 2024
@ivailop7 ivailop7 added the extended-tests Run extended e2e tests on a PR label Nov 8, 2024
Copy link
Collaborator

@ivailop7 ivailop7 left a 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.

Copy link
Collaborator

@etrepum etrepum left a 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?

@etrepum etrepum added this pull request to the merge queue Nov 8, 2024
Merged via the queue into facebook:main with commit fd4aca7 Nov 8, 2024
40 of 43 checks passed
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.

4 participants