lexical icon indicating copy to clipboard operation
lexical copied to clipboard

Bug: Unable to input any CJK language with google input tool

Open kalvin807 opened this issue 3 years ago • 5 comments

Lexical version: 0.10.0

Steps To Reproduce

  1. Install Google input tool at google chrome store https://chrome.google.com/webstore/detail/google-input-tools/mclkkofklkfljcocdinagocijmpgbhab
  2. Open playground
  3. Enable a CJK language (e.g Cantonese)
  4. Enter any word (e.g neihou for 你好)
  5. Caret flashes but cannot input any word

https://github.com/facebook/lexical/assets/46393179/5c802f68-c28e-484c-81b4-a1645812d2f4

Link to code example:

The current behavior

It seems like that any input made by using the input suggestion will bugged. I wonder if this may relate to https://github.com/facebook/lexical/pull/3846 because the bug visually look the same

The expected behavior

The word can be entered properly

kalvin807 avatar May 29 '23 14:05 kalvin807

Your code pointer is spot on, it always happens at start of line which is when we have to run additional logic to fix inconsistencies and also create the first TextNode when this doesn't exist.

Unfortunately, I can't think of an easy way to target this event, besides maybe doing document.getElementByID('GOOGLE_INPUT_CHEXT_FLAG')

Screenshot 2023-06-01 at 10 03 59 am

Perhaps we should invert the logic to have if (IS_ANDROID) instead but we'd have to test this logic carefully on Windows and Linux not to cause a major regression.

For reference, this is the PR that added it https://github.com/facebook/lexical/pull/1661/

zurfyx avatar Jun 01 '23 14:06 zurfyx

submitted a fix at https://github.com/facebook/lexical/pull/4783

kalvin807 avatar Jul 15 '23 05:07 kalvin807

@zurfyx bumping on this issue because I can't type with googleIME in all product that uses lexical :( Please check the PR if this is good enough to patch for now 🙏

kalvin807 avatar Sep 06 '23 04:09 kalvin807

Hi @kalvin807, do you still encounter CJK input problems with Google Input Tools?

It seems to work for me now, at least on Google Chrome 125.0.6422.176 on macOS.

https://github.com/facebook/lexical/assets/25148955/d4101dfc-a92a-4e37-8d9c-e1d19eadc842

dragonman225 avatar Jun 15 '24 17:06 dragonman225

PR #4783 (the proposed fix) was closed without merging, and a commenter confirmed this works on Chrome 125 (June 2024). Tested again with Google Input Tools on the latest Chrome — CJK input works correctly.

The relevant Lexical code path ($updateTextNodeFromDOMContent's empty text node removal branch) did not change between v0.10.0 and the time it started working, so this was not fixed on the Lexical side. If there are no further reproduction reports, this can probably be closed.

mayrang avatar Jun 26 '26 08:06 mayrang