Open hesamat opened 6 years ago
The typed content doesn't actually get added to the editor until a compositionend
event, which is why the placeholder addon doesn't notice it until that point. That's not great, and in the next overhaul of the library we'll probably set things up so that each compositionupdate
immediately updates the editor, but for now that's tricky to change.
Maybe we could add event handlers to the placeholder to hide the placeholder when a composition event starts, and when it ends, re-check whether it should be shown depending on the editor content. Would you be able to create a pull request to that effect?
Sure. I will give it a shot sometime next week.
@marijnh @hesamat was this issue ever resolved? I am not able to get the on change event to trigger on an ANDROID device unless a space or special character has been entered.
I was able to trigger the necessary event listener by appending a space to the value of the editor before trying to access that value.
editor.codemirror.replaceRange(" ", {line: Infinity});
Edit: this fix doesn't work in every case, it will cut off parts of words and not recognize all typed characters still
@dmortimer No it wasn't resolved. I ended up using a hack to address the issue back then.
As Marijn mentioned we are working on a rewrite (CodeMirror 6) that will overhaul input handling and he is planning to address this issue. We are currently raising money for this work: See the announcement for more information about the rewrite and a demo.
Note that CodeMirror 6 is by no means stable or usable in production, yet. It is highly unlikely that we pick up this issue for CodeMirror 5, though.
Repro steps: 1- Open the placeholder demo page in Chrome on Android. (I am testing on Android 7.1.1, Chrome 64). 2- Start typing non-special characters
Result: Placeholder won't disappear.
I did a little bit of investigation on this. It looks like the compositionend event is not triggered unless you press space/a special character. One possible solution would be to listen for keyup event on Android rather than the compositionend event.