facebook / facebook/lexical

Bug: [iframe] Editing a LinkNode Inserts an Extra Span When Modifying Text Before the Last Character

Open
#7,123 2 comments 0 reactions 0 assignees View on GitHub
iframe
Dominant language
TypeScript
Stars
23.9k
Forks
2.2k
Avg merge
1d 14h
Merged PRs (30d)
55

Description

Editing LinkNode cause another span to be created after the LinkNode, happens only if we start to add characters before the last character of the LinkNode.

Lexical version: 0.20.0

## Steps To Reproduce

1. open the provided CodeSandbox
2. you will find a link already in the document "Lexical"
3. put the cursor between 'a' and 'l' and start typing
4. you will find that another span is been created after the linkNode, so 2 spans been updated at the same time

Link to CodeSandbox example:
https://stackblitz.com/edit/facebook-lexical-3ztsmofg?file=src%2Fmain.ts,package.json,src%2FprepopulatedRichText.ts

## The current behavior
a new span been created and updated

## The expected behavior
No spans been created just the current LinkNode been updated

https://github.com/user-attachments/assets/e7968400-7187-4a86-add3-92a6e805ecac

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.