From ec16a0c1e0e8494fe30dcf6cf60be3260e8a440f Mon Sep 17 00:00:00 2001 From: Rob Garrison Date: Wed, 19 Sep 2018 08:27:29 -0500 Subject: [PATCH] Remove onblur, don't save invalid inputs --- manage/config-dialog.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/manage/config-dialog.js b/manage/config-dialog.js index 697e1740..eae129a3 100644 --- a/manage/config-dialog.js +++ b/manage/config-dialog.js @@ -264,7 +264,6 @@ function configDialog(style) { va, type: va.type, onfocus: va.type === 'number' ? selectAllOnFocus : null, - onblur: va.type === 'number' ? updateVarOnBlur : null, onchange: updateVarOnChange, oninput: updateVarOnInput }; @@ -317,19 +316,15 @@ function configDialog(style) { this.va.value = Number(this.value); $('.current-value', this.closest('.config-range')).textContent = this.va.value + (this.va.units || ''); } else if (this.type === 'number') { - // clamp stored value - this.va.value = clampValue(this.value, this.va); + const value = Number(this.value); + if (clampValue(value, this.va) === value) { + this.va.value = value; + } } else { this.va.value = this.type !== 'checkbox' ? this.value : this.checked ? '1' : '0'; } } - // Applied to input[type=number] - function updateVarOnBlur() { - // clamp value visible to user - this.value = this.va.value = clampValue(this.value, this.va); - } - // Clamp input[type=number] to a valid range function clampValue(value, va) { // Don't restrict to integer values if step is undefined.