Open laurentsenta opened 4 years ago
I'd be happy to contribute if you need a hand,
Could you give me some context? It looks like the code is designed to handle escape, so this looks like a bug rather than a new feature.
Thanks for opening the issue. When a user press "escape",
emitEscEvent
at L98customEvent.preventDefault()
if the dropdown is shown.mouseEvent.preventDefault()
is called at L100-L102.@laurentsenta @yuku Hello guys, I cannot reproduce this, nor find a PR, has this been fixed in another PR? @laurentsenta would you please share the browser and version you are using?
Here's how you can fix this locally:
class CodeMirrorEditor2 extends CodeMirrorEditor {
constructor(cm: CodeMirror.Editor) {
super(cm);
(this as any).stopListening();
(this as any).onKeyup = (_cm: CodeMirror.Editor, e: KeyboardEvent) => {
const code = this.getCode(e);
if (code !== 'DOWN' && code !== 'UP' && code !== 'ESC') {
this.emitChangeEvent();
}
};
(this as any).startListening();
}
}
FYI this issue only happens with CodeMirror editor, which assumes that all the keys, except 'DOWN' and 'UP' should trigger a change event, which in turn re-opens the dropdown. I have added a third exclusion for the 'ESC' key in the above code.
I get this behavior in my code and on the demo page: https://yuku.takahashi.coffee/textcomplete/
:s
or something so that the autocomplete dropdown shows up,