I have been spending a few days trying to fix this issue with autocomplete on android phones and just realized that it also occurs on all of codemirror’s official autocomplete examples, so it is probably not something I can fix on my end.
This is a little tricky to reproduce because you need to have an android phone and type quickly (I specifically noticed it using the default Samsung Browser on a Samsung Galaxy S10+), but basically the reproduction steps are:
Go to any of the codemirror autocomplete examples: (like this one)
Start a completion (e.g. type ‘p’)
Quickly backspace
Notice that pressing ‘Enter’ does nothing now. It doesn’t accept the completion, and it doesn’t insert newlines. The autocomplete seems stuck. Even when you tap one of the options, the ‘Enter’ key still doesn’t work for inserting newlines anymore.
I can reproduce this with other keyboards as well (though not with GBoard). What appears to be happening is that, if you immediately backspace out the first letter of a new word, the browser doesn’t end the composition that it started when you started the word, leaving CodeMirror believing that the user is still composing (in which case it should block normal handling of Enter). I’ve isolated this and filed a Chrome bug.
(This had nothing to do with autocomplete, by the way. It happens the same when there’s no autocompletion active.)
Attached patch kludges around this and seems to resolve the issue.
Awesome! I’ve tested it, and it looks like it no longer gets stuck, but I’m still seeing other inconsistent behavior on mobile vs desktop with completions.
For example, in the codemirror custom completions example, if I open it on desktop, type ‘p’ and backspace, the completions close (correct behaviour). But if I open it on my Samsung Galaxy, type ‘p’ and backspace, the completions don’t close (incorrect behaviour).
A bit late, but I just wanted to report that with the latest update of @codemirror/view this seems to be working now! I haven’t found any other autocomplete problems on Android so far. Thanks for the quick fixes!