Skip to content

Commit da8a35d

Browse files
committed
Handle compositionupdate events without corresponding compositionstart
Because Android, especially Google Keyboard, just doesn't care
1 parent 5012e87 commit da8a35d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/input/ContentEditableInput.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ ContentEditableInput.prototype = copyObj({
3737
}), 20)
3838
})
3939

40-
on(div, "compositionstart", e => {
41-
let data = e.data
40+
function startComposing(data) {
4241
input.composing = {sel: cm.doc.sel, data: data, startData: data}
4342
if (!data) return
4443
let prim = cm.doc.sel.primary()
@@ -47,8 +46,13 @@ ContentEditableInput.prototype = copyObj({
4746
if (found > -1 && found <= prim.head.ch)
4847
input.composing.sel = simpleSelection(Pos(prim.head.line, found),
4948
Pos(prim.head.line, found + data.length))
49+
}
50+
51+
on(div, "compositionstart", e => startComposing(e.data))
52+
on(div, "compositionupdate", e => {
53+
if (input.composing) input.composing.data = e.data
54+
else startComposing(e.data)
5055
})
51-
on(div, "compositionupdate", e => input.composing.data = e.data)
5256
on(div, "compositionend", e => {
5357
let ours = input.composing
5458
if (!ours) return

0 commit comments

Comments
 (0)