lexical icon indicating copy to clipboard operation
lexical copied to clipboard

Bug: Using AOSP-based keyboards on Android is very broken

Open amanharwara opened this issue 2 years ago • 2 comments

Lexical version: 0.13.1

Steps To Reproduce

  1. Use an AOSP-based keyboard like OpenBoard or FlorisBoard. Even happens with old versions of Gboard.
  2. Type a few words and make one in the middle formatted differently so that the text node is split into multiple text nodes.
  3. Press around different places

Link to code example:

Happens on the Playground https://playground.lexical.dev

The current behavior

https://github.com/facebook/lexical/assets/8348101/89c096dc-4f23-4543-a2a4-aae40187490f

You'll notice a space being added wherever you press inside the formatted word, and at the end of the non-formatted word if you press inside those. Occasionally it will also duplicate the word you previously had the cursor in to wherever you press next.

The expected behavior

No extra spaces should be added anywhere and no words should be duplicated.

amanharwara avatar Feb 23 '24 13:02 amanharwara

I think this might have something to do with the COMPOSITION_SUFFIX that is added to text nodes when composing (https://github.com/facebook/lexical/blob/main/packages/lexical/src/nodes/LexicalTextNode.ts#L221). AOSP-based keyboards seem to be triggering composition any time the cursor is within a word.

amanharwara avatar Feb 23 '24 14:02 amanharwara

Tested on current main with HeliBoard (AOSP-based keyboard) on a Galaxy device — tapping around formatted/unformatted word boundaries no longer adds extra spaces or duplicates words. PR #7725 (offset clamping in $internalResolveSelectionPoint) likely addresses the offset mismatch caused by the ZWSP composition suffix.

Note: tested with HeliBoard, not the original OpenBoard or FlorisBoard — if anyone can still reproduce, please reopen.

mayrang avatar Jun 27 '26 13:06 mayrang