Skip to content

Commit 5559e00

Browse files
committed
Work around lack of compositionend events in EditContext on Android
FIX: Work around a Chrome Android issue where the browser doesn't properly fire composition end events, leaving CodeMirror to believe the user was still composing. See https://discuss.codemirror.net/t/autocomplete-gets-stuck-and-permanently-breaks-enter-key-when-quickly-backspacing-on-android/9514
1 parent 31ffdc5 commit 5559e00

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/domobserver.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,12 @@ class EditContextManager {
585585
this.revertPending(view.state)
586586
this.setSelection(view.state)
587587
}
588+
589+
// Work around missed compositionend events. See https://discuss.codemirror.net/t/a/9514
590+
if (change.from < change.to && !change.insert.length && view.inputState.composing >= 0 &&
591+
!/[\\p{Alphabetic}\\p{Number}_]/.test(context.text.slice(Math.max(0, e.updateRangeStart - 1),
592+
Math.min(context.text.length, e.updateRangeStart + 1))))
593+
this.handlers.compositionend(e)
588594
}
589595
this.handlers.characterboundsupdate = e => {
590596
let rects: DOMRect[] = [], prev: DOMRect | null = null

0 commit comments

Comments
 (0)