#1103 vnTextfield doesnt blur anymore

This commit is contained in:
Gerard 2019-02-26 17:33:51 +01:00
parent a37fdd1e33
commit 60ec49abbd
1 changed files with 7 additions and 10 deletions

View File

@ -18,18 +18,15 @@ export default class Textfield extends Input {
if (!this.oldValue)
this.saveOldValue();
});
this.input.addEventListener('keyup', e => {
if (e.key == 'Escape') {
this.value = this.oldValue;
this.cancelled = true;
e.stopPropagation();
}
if (e.key == 'Escape' || e.key == 'Enter')
this.input.blur();
});
if (e.defaultPrevented || e.key != 'Escape')
return;
this.input.addEventListener('blur', () => {
this.value = this.oldValue;
this.cancelled = true;
e.preventDefault();
});
this.input.addEventListener('change', e => {
if (this.onChange && !this.cancelled && (this.oldValue != this.value)) {
this.onChange();
this.saveOldValue();