From 60ec49abbd81a532452dc7a850d6480ea182b35d Mon Sep 17 00:00:00 2001 From: Gerard Date: Tue, 26 Feb 2019 17:33:51 +0100 Subject: [PATCH] #1103 vnTextfield doesnt blur anymore --- front/core/components/textfield/textfield.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/front/core/components/textfield/textfield.js b/front/core/components/textfield/textfield.js index f47b3de374..88a585eda5 100644 --- a/front/core/components/textfield/textfield.js +++ b/front/core/components/textfield/textfield.js @@ -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();