facebook / lexical

Lexical is an extensible text editor framework that provides excellent reliability, accessibility and performance.
https://lexical.dev
MIT License
19.99k stars 1.71k forks source link

Bug: The paste command does not replace all selected elements #5358

Open vadim-kudr opened 11 months ago

vadim-kudr commented 11 months ago

Lexical version: 0.12.4 current on https://playground.lexical.dev/

Steps To Reproduce

  1. Go to https://playground.lexical.dev/
  2. Insert collapsible element
  3. Copy (cmd+a + cmd+c) and paste then as second element
  4. Select all by cmd+a
  5. Paste collapsible element

The current behavior

We have 3 elements:

image

The expected behavior

We have 1 pasted element

ivailop7 commented 11 months ago

I'm unable to reproduce this one, could we get a video?

vadim-kudr commented 11 months ago

Yes, sure

https://github.com/facebook/lexical/assets/2942698/2bffef1c-dd68-4a99-a6d0-ccd9887ac10c

ivailop7 commented 11 months ago

Thanks! Managed to repro, when pasting after a SELECT_ALL command, it doesn't seem to replace the selection, but rather append to it. This is an interesting one.

ivailop7 commented 11 months ago

It doesn't happen if there is any text inside the editor, which is why I wasn't able to reproduce it originally. So it's most likely related to selection.