facebook / facebook/lexical

Bug: incorrect "redo" behavior with nested editor

Open
#4,401 4 comments 3 reactions 0 assignees View on GitHub
all-platforms-bug history
Dominant language
TypeScript
Stars
23.9k
Forks
2.2k
Avg merge
1d 14h
Merged PRs (30d)
55

Description

I noticed a bug while trying to share a history stack across a parent and nested editor. I manually created a history stack and passed it the `HistoryPlugin` for both editors.

Unfortunately, the "redo" behavior isn't working as expected. When making edits in both editors, only the child's content is restored. There's a point in the "redo" stack where the parent's content should be restored, but only the selection changes.

Lexical version: 0.10.0

## Steps To Reproduce

1. Edit text in parent editor
1. Edit text in image caption
1. Undo caption edit
1. Undo parent edit
1. Redo parent edit (fails! Jumps to caption editor, but does not reinstate text)
1. Redo caption edit

https://user-images.githubusercontent.com/739390/234023118-9a37672a-a6c2-49e2-939f-f968992016eb.mov

Link to code example: https://playground.lexical.dev/

## The current behavior

The parent editor's selection is restored, but not its content.

## The expected behavior

The parent editor's selection and content are restored.

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.