From b7765cee7de37342cc2015998134d5b2862c1071 Mon Sep 17 00:00:00 2001 From: bordun Date: Sat, 6 Feb 2021 11:23:25 +0100 Subject: [PATCH] input: submit content when leaving focus, not only when hitting `enter` or `tab` (`esc` still cancels) --- CHANGELOG.md | 1 + src/client/widgets/basics/input.js | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f664a98..df177e98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - bug fixes - input: prevent focus when selecting the widget for edition + - input: submit content when leaving focus, not only when hitting `enter` or `tab` (`esc` still cancels) - midi - display an error when the midi bridge process crashes and prevent further errors when attempting to send messages diff --git a/src/client/widgets/basics/input.js b/src/client/widgets/basics/input.js index d38532bc..a70e62e7 100644 --- a/src/client/widgets/basics/input.js +++ b/src/client/widgets/basics/input.js @@ -43,7 +43,6 @@ class Input extends Canvas { this.value = '' this.stringValue = '' this.focused = false - this.tabKeyBlur = false this.validation = null if (this.getProp('vertical')) this.widget.classList.add('vertical') @@ -57,8 +56,7 @@ class Input extends Canvas { this.widget.addEventListener('focus', this.focus.bind(this)) this.input = html`` this.input.addEventListener('blur', (e)=>{ - this.blur(this.tabKeyBlur) - this.tabKeyBlur = false + this.blur(true) }) var asYouType = this.getProp('asYouType') @@ -75,7 +73,6 @@ class Input extends Canvas { this.input.addEventListener('keydown', (e)=>{ if (e.keyCode === 13) this.blur() // enter else if (e.keyCode === 27) this.blur(false) // esc - else if (e.keyCode === 9) this.tabKeyBlur = true // tab else if (asYouType) { setTimeout(()=>{ this.inputChange()