Skip to content

Bug: The cursor moves to the end of the LinkNode when merging identical links #8305

@levensta

Description

@levensta

Lexical version: 0.42.0

Steps To Reproduce

  1. Create identical link nodes around a regular text node. For example, you can remove the link part in the middle of the text.
  2. Remove the plain text between the two links

Link to code example: https://playground.lexical.dev/#doc=H4sIAAAAAAAAE9VSy04DMQz8FTTnqNuWPiAfwIkDUo-IQ9iYNqqbrLze0qraf0fZpZRyqETFhVM8Y9kzHuUA8kGTLNQpwR4gKWl-y1VgLxRhny8BT-oCww4N3pJsnHblJnmCRcwMw6DWPWcCBko7hcUj7ULp-CYz-yr3uobBlqQOKcKO2hcDH4RK7XBsmE8ieVWInmIv-LmDQ1yf7TAQ4uOsOlmSfqGg2VMPGmFYrFSr2hYF9-YGnrYFWnP9le_0eulA80dh1kHpHwT5exuVE7cUV61-eMknPpwSynBxTOUKme7PnyXWGrCrdeG25GFH8_l0Orud3U3Gk3uDOjVS5rkndvulpCb679MYDibjwRDtB6Oc0AtcAwAA

The current behavior

After deleting the text between the links, the links are merged into one node, but the cursor moves to the end of the node

merging.links.cursor.mov

The expected behavior

The link nodes are merged into one, but the cursor remains

Impact of fix

Link merging is a useful feature that prevents the creation of unnecessary nodes #8236, but it is important to leave the cursor in the same position after deleting the last character of a TextNode to avoid spoiling the UX.

Metadata

Metadata

Assignees

No one assigned

    Labels

    hyperlinksRelates to Lexical Links

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions