-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The editor can't be focused or the selection can't be correctly updated after input with IME #2149
Comments
Here is my analysis of the problem (Chrome 68.0.3440.106 under Mac): During IME composition, after I input three characters "fff": the onSelection event is fired to the editor. In In the screenshot, the selection means "native selection", the offset is 5. After changing the code to as following, IME can work in the "Input Tester" example:
In
So I think during IME composing, the selection event should not be handled in |
@freeplant some ongoing discussion and works regarding IME and mobile on #2062 |
@isubasti Thanks for the notice. |
Feels like a similar problem to Android. This issue is a good candidate for being solved by #2062 by waiting for the DOM to be in a stable state before a re-render is done. I solved a similar issue by finding the right event (not always |
I find the cause of the last character "f" can't be focused. During IME composing, if you left the editor (focus on other elements out side of the editor). The inputed characters will be left in the DOM, but not in the slate document. So the characters are not @thesunny #2062 should solve the problems. But I wonder if there is a short-term solution. There are two issues I see so far with IME on desktop:
The second issue can be easily fixed. |
Here is the events sequence during IME when user input a letter then input a number to select the candidate:
Here is the events sequence during IME when user input a letter then focus out:
The text is ignored by Slate but left in the DOM. Waiting for the DOM to be in a stable state than using Diff to get the actual text can solve the problem. Another solution is to remember the temporary text during |
Can't remember what Slate was doing in the current version but there is a general issue with browsers being that the state during a composition is not consistent so even if the event fires, the DOM might not be what we expect at that moment. Try this modified input tester https://thesunny.github.io/input-methods/index.html which outputs the DOM and cursor position during the event cycle. May help you figure out what's happening. Without it, I couldn't figure out the Android issues. |
Closing in favor of #2368, if you think this is unrelated let me know and we can reconsider. |
@ianstormtaylor I'm having very similar issues with a plugin I'm writing, but it doesn't involve IME. The text I'm trying to select is in div with Do you have any idea? Do you think it's related? |
Do you want to request a feature or report a bug?
report a bug
What's the current behavior?
During our daily use of Slate, we occasionally encounter a problem that the editor can't be focus or the selection can't be updated after inputting characters with IME. The problem can be easily reproduced with the Input Tester on the demo site (maybe it is due to the "Input Tester" update the rendered react components for every event to show the event list). Here is the screenshot:
Whenever I want to put the focus after the last character "f", it changes back to before "f".
Currently I think the problem is caused by the following code:
content.js:
Currently I'm trying to locate and resolve the problem. Any hints are welcome.
The text was updated successfully, but these errors were encountered: