lexical icon indicating copy to clipboard operation
lexical copied to clipboard

Bug: select all + delete should remove all blocks

Open OleksandrDubovchenko opened this issue 1 year ago • 1 comments

When doing select all (e.g. ctrl + A or cmd + A on Mac - I think), and then pressing delete or backspace, my expectation would be that all of the content is completely erased, including any blocks, and instead you'd get the same thing you'd get when loading an editor instance without initial state: an empty paragraph block.

Instead, what happens is that everything is removed, but the remaining block is what the first block already was, except empty. For example, if the first block was a list item, it will remain after following this process, but empty.

Lexical version: 0.14.3

Steps To Reproduce

1.Put some stuff on the editor. Make sure the first block is not a paragraph block. 2. Select all. 3. Delete

Link to code example: Link to sandbox

The current behavior

https://github.com/facebook/lexical/assets/126766271/004fa505-ddf5-402f-9b01-8fd488893483

The expected behavior

Editor is clear after delete is pressed

P.S Same bugfix was closed, but seems, that problem is still reproducable https://github.com/facebook/lexical/issues/3682

OleksandrDubovchenko avatar Apr 05 '24 13:04 OleksandrDubovchenko

Yeah, I can repro when the bullet list is the first node. Still valid as of 0.16.0

ivailop7 avatar Apr 05 '24 17:04 ivailop7

Still valid in v0.21.0. I think this is basically another presentation of #6086 - the selection anchor or focus always migrates to the TextNode during normalization and our delete code doesn't have a special-case to handle this just like copy doesn't.

etrepum avatar Dec 03 '24 05:12 etrepum