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

[Breaking Change][lexical][lexical-link] Bug Fix: Collapse through inline elements in deleteCharacter #7180

Merged
merged 2 commits into from
Feb 15, 2025

Conversation

etrepum
Copy link
Collaborator

@etrepum etrepum commented Feb 14, 2025

Breaking Change

ElementNode.collapseAtStart(range) would previously only be called on the direct parent of the anchor's node, so the presence of anything like a LinkNode would prevent a ListItemNode from collapsing. Now it will also be called on parents under certain conditions.

Description

Previously the collapse algorithm looked only at the direct parent of the anchor. If the anchor is inside an inline node (e.g. a TextNode in a LinkNode) then the expected behavior will not happen (such as a LinkItemNode being replaced with a ParagraphNode).

Now the algorithm works like this:

  • Start with the anchor node (if its offset is 0) and then all of its parents:
    • If the current node is an ElementNode
      • If node.collapseAtStart(range) returns true, stop
      • If node.isInline() returns false, stop
    • If the node is not the first child of its parent, stop

Closes #7150

Test plan

e2e tests for new behavior

Before

Pressing delete at the beginning of a ListItemNode would not collapse the node if the anchor was inside of an inline element (such as a LinkNode)

After

Pressing delete at the beginning of a ListItemNode collapses through inline element node(s) as expected

Copy link

vercel bot commented Feb 14, 2025

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 Feb 15, 2025 5:51am
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 15, 2025 5:51am

@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 Feb 14, 2025
@etrepum etrepum added the extended-tests Run extended e2e tests on a PR label Feb 14, 2025
@ivailop7 ivailop7 added this pull request to the merge queue Feb 15, 2025
Merged via the queue into facebook:main with commit f505ffe Feb 15, 2025
39 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.

Bug: Can't delete first list item with link
3 participants