facebook / lexical

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

Bug: Selection bug when using multiple editors (vanilla JS) #5476

Open rmadeiraneto opened 10 months ago

rmadeiraneto commented 10 months ago

Lexical version: 0.12.6

Steps To Reproduce

  1. click on (focus) the editable container inside the iframe
  2. type something
  3. select all the content inside
  4. click on the 'change font' button
  5. click on the middle of the text that you typed on the point 2
  6. type more text
  7. [the behavior should be what is expected: everything with the same font] (image 1)
  8. change the code: on line 12 of the index.js file, change the constant nEditors to 2
  9. run the code
  10. repeat steps 1 to 6 on both editors
  11. [the characters that you typed after the font change have a different font] (image2)

image step 7

image step 11

Link to code example

The current behavior

When I have two editors (using iframes), and I change a selection's font family with $patchStyleText, change the cursor to the middle of the text, and start typing again, it won't identify the correct node and just inserts a new node (unstyled), so the fonts of the (now 3) nodes won't match.

The expected behavior

(like it's behaving when I have only one editor) I change a selection's font family with $patchStyleText, change the cursor to the middle of the text, and start typing again, it would identify the node I'm typing at, which has a 'non-default' font family and it would just add what I'm typing inside, so it would just be one single node with the font family I set.

rmadeiraneto commented 9 months ago

Does anyone has also faced this issue?