facebook / lexical

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

Bug: The beginning of a TextNode with canInsertTextBefore false in Asian languages It is not replaced when it is replaced #5162

Open matsuyama-k1 opened 1 year ago

matsuyama-k1 commented 1 year ago

Lexical version: V0.12.2

Steps To Reproduce

  1. Create a Node that inherits TextNode and canInsertTextBefore is false. (ex. HashtagNode) Screenshot 2023-10-24 at 22 21 41

  2. Select text from the beginning of the corresponding node Screenshot 2023-10-24 at 22 30 48

  3. Type Asian language such as Japanese and Chinese. (Languages that trigger node.isComposing() to be true)

  4. In addition to not displaying text input, it becomes impossible to change the selection using mouse clicks, etc. Screenshot 2023-10-24 at 22 38 12

  5. You can return Selection to selectable by pressing enter, but the design will collapse and the entered text will not be reflected. Screenshot 2023-10-24 at 22 46 03

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

The current behavior

If you select a Node for which canInsertTextBefore is False from the beginning and enter an Asian language that sets node.isComposing() to True, the text will not be displayed and the selection will not be able to be changed.

The expected behavior

Even if you select a Node for which canInsertTextBefore is False from the beginning and enter an Asian language that sets node.isComposing() to True, act as same with English input.

matsuyama-k1 commented 1 year ago

Maybe the situation is related to this function. https://github.com/facebook/lexical/blob/df2a50bc88e0778af26e109502cfcfb9cbe245d5/packages/lexical/src/LexicalUtils.ts#L598