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

Preserve empty parent during replacement #3595

Merged
merged 1 commit into from
Dec 20, 2022
Merged

Preserve empty parent during replacement #3595

merged 1 commit into from
Dec 20, 2022

Conversation

fantactuka
Copy link
Contributor

@fantactuka fantactuka commented Dec 19, 2022

When node is being replaced we should preserve its empty parent (in case it has canBeEmpty: false), as otherwise parent might be deleted and replacement fail. E.g., LinkNode has canBeEmpty: false and attempting to replace its text node child would fail.

Will add test, want to see CI results in case I've missed anything

@vercel
Copy link

vercel bot commented Dec 19, 2022

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

Name Status Preview Comments Updated
lexical ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Dec 20, 2022 at 3:15AM (UTC)
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Dec 20, 2022 at 3:15AM (UTC)

Copy link
Contributor

@thegreatercurve thegreatercurve left a comment

Choose a reason for hiding this comment

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

LGTM. Accepting to unblock, but maybe @trueadm would have the best insights here.

@acywatson
Copy link
Contributor

acywatson commented Dec 19, 2022

#1802

It would probably break some things, but I'm still personally of the opinion that this behavior should be the default. It's not intuitive that removing a specific node would also sometimes remove it's parent. At the same time, it is convenient to not have to check emptiness on your own every time you remove a node.

@fantactuka
Copy link
Contributor Author

Pure removal might require parent cleanup but as a part of replacement it does not make much sense

@fantactuka fantactuka merged commit 6db97e7 into main Dec 20, 2022
@fantactuka fantactuka deleted the fix-replacement branch December 20, 2022 14:19
@trueadm trueadm mentioned this pull request Dec 23, 2022
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.

None yet

5 participants