A couple of problems with core plugin onBeforeInput
See original GitHub issueWhile investigating IME bugs, I came across a few problems with onBeforeInput
in the core plugin:
- Is it assumed here that
e.data
will contain a single character?
In the case of a composition event, onBeforeInput
will receive the entire composed string in e.data
just before calling the compositionend
event, so instantiating a Character with a multiple-char string may break somewhere. (At fist impression, seems the list insertion works either way)
- I understand this line should mimic what a native insertion would be?
If that’s the case, it should take the selection into consideration, since you may be actually replacing some characters in the process.
This is all I have for now in regards to inserting composed words, I’ll keep investigating — is there any other place that assumes e.data is a single char but then ends up pushing a multi-character string into the state? That may be the source of some of the problems we currently have with IMEs.
Right now I reckon these are causing:
- Unnecessarily using a non-native insertion when it could have been native, due to mismatch between computing “native” outcome vs. “synthetic” outcome
- Noticing that when overwriting text with a composed word, the outcome of the “synthetic” action is not accurate (selection is out of sync in the meantime), but the “native” one is, allowing a native insertion might fix some bugs.
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (7 by maintainers)
Top GitHub Comments
Hi, sorry for the hiatus — I’m back on the problem. I noticed the recent merge that removed
isNative
, I’d need to get back to speed with the problem and see how it impacts (in my previous tests, disablingisNative
did not have a major impact on IME problems unfortunately).Thanks for your insights @danburzo:
onBeforeInput
, the current selection must be considered.SyntheticEvent
andDOMEvents
, since this would be a React issue, not a Slate one.Context
Proposed approach
SyntheticEvent
sequences and the resulting HTML on different OS versions (Android 4.0, 4.1, 4.4, 5.0, 6.0, 7.0, 8.0, and iOS).The source code of the event watcher is available in this fork.