facebook / facebook/lexical

Bug: : Undo of list indentation in collaborative editor (Yjs) causes cursor to jump to the previous line

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

Description

If you indent a list item, unindent and press undo, the cursor jumps to the previous node, this causes some issues with the editor sometimes scrolling to a "random" location after pasting something in a list and undoing that. From what I can tell it's creating new nodes with different keys after the undo command, unlike the History Plugin, which is maybe why it can't restore the selection correctly.

https://github.com/user-attachments/assets/4de71261-f345-4ce5-9365-5b1cdd054c61

Lexical version: v0.30.0+dev.esm (Latest playgtound)

## Steps To Reproduce

1. Create two list items, select the start of the second one and indent it using tab.
2. Undo your change, the cursor jumps to the previous lines.

Link to code example:

https://playground.lexical.dev/?isCollab=true

## The current behavior

The cursor "jumps" to another node.

## The expected behavior

The cursor is where it was originally after the undo.

## Impact of fix

Although not extremely severe, this bug has been reported several times internally, causing issue with "random" scrolling when copy pasting or editing lists.

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.