As mentioned in my previous post, we’re developing an extension that conditionally adds a decorator widget to empty lines. However, when we began to roll this out, we noticed a bug that is strangely only affecting users on Android.
Our extension appends an absolutely positioned element to empty lines.
On iOS Safari and Chrome/FF on desktop, this works just fine. However, when using the app on Android (Chrome), we’re encountering a bug that prevents you from deleting an empty line via backspace (instead of removing the line, the virtual keyboard just closes and nothing is deleted). It also prevents you from selecting an empty line in the first place (the touch events just seem to be ignored and the cursor does not move).
I’ve put together a minimal repro in this repl (which is hosted here):
Let me know if this really is a bug in CodeMirror or if there is some workaround. Alternatively, if we’re doing something wrong here, I would love to hear your thoughts on what you think the best approach is for overlaying an element over a line in a way that doesn’t conflict with its content or interfere with editing.
This is definitely a bug (or several bugs) in Chrome, but since it hasn’t been getting addressed for ages, I guess it’s on CodeMirror to work around it. This patch provides a first stab at such a workaround. Could you give it a try and let me know how it works for you?
Ah, scratch that. I accidentally committed something that wasn’t intended to be included yet with that patch, and the reduced version doesn’t solve all problems yet. Going to continue debugging this.
Okay, this patch implements #539, which should help a lot with this (and also address the weird cross-widget-boundary composition bug in Chrome). However, it is a rather scary change so I’m not cutting a release until it sees a little more testing (if you can help with that testing that’d be wonderful).
Thanks so much Marijn! Appreciate the help with this.
Happy to help test this. Let us know what we can do to move this forward. For example, what the testing workflow looks like and what exactly we should be testing for? Are there any relevant automated tests for this behavior or is it all manual at this point?
Thanks for all your recent patches! They definitely helped since now backspacing over a widget “works” (e.g. the character gets deleted), but unfortunately the virtual keyboard is still flickering briefly which prevents you from long pressing to delete multiple lines with widgets.
I’ve opened an issue on GH with more detail here: Keyboard flicker when backspacing next to widget on Android · Issue #602 · codemirror/codemirror.next · GitHub
As always, let me know how I can help!
Just a heads-up that this patch changes the way Android beforeinput handling works once again, to avoid changes being dropped by that mechanism. I quickly tested your old demo with the current code and it seems to still work, but let me know if you run into any regressions.