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-list] Bug Fix: Handle appending inline element nodes in ListNode.append #6791

Merged

Conversation

amanharwara
Copy link
Contributor

Currently, ListNode.append will always convert an element node into a text node, even if the element node is inline and can be appended as a whole which can end up removing formatting and unwrapping things like links.

While this is rarely hit, since most of the code in the lexical codebase accounts for appending to a child list item instead of the list directly, I think it still makes sense for this to be correct.

Copy link

vercel bot commented Nov 4, 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 4, 2024 2:15pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 4, 2024 2:15pm

@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 4, 2024
Copy link

github-actions bot commented Nov 4, 2024

size-limit report 📦

Path Size
lexical - cjs 29.94 KB (0%)
lexical - esm 29.78 KB (0%)
@lexical/rich-text - cjs 38.59 KB (0%)
@lexical/rich-text - esm 31.65 KB (0%)
@lexical/plain-text - cjs 37.25 KB (0%)
@lexical/plain-text - esm 28.94 KB (0%)
@lexical/react - cjs 40.32 KB (0%)
@lexical/react - esm 33.01 KB (0%)

@ivailop7 ivailop7 added the extended-tests Run extended e2e tests on a PR label Nov 4, 2024
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.

A test would be nice to demonstrate that this works as expected, but otherwise it seems like a positive change. I do wonder if this would be better done in a transform because there are other ways to violate this invariant (e.g. listItemNode.replace(textNode)).

Also makes me think that the implementation of node.replace(otherNode) should probably delegate to the containing ElementNode (like in the DOM API), right now it just swaps the pointers.

@potatowagon potatowagon added the test-needed Merged PRs that could do with more test coverage label Nov 11, 2024
@potatowagon potatowagon added this pull request to the merge queue Nov 11, 2024
Merged via the queue into facebook:main with commit 2bdaed5 Nov 11, 2024
69 of 73 checks passed
@amanharwara amanharwara deleted the append-inline-elements-to-list branch November 11, 2024 19:23
@Shopiley
Copy link
Contributor

Hi, I've added a test for this bug fix here: #6826

also wanted to point out that this PR fixes issue #6793 so we can close that.

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 test-needed Merged PRs that could do with more test coverage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants