From 0290b0a693e9a963eda0b2ebacc7e55d8c6a456f Mon Sep 17 00:00:00 2001 From: Simon Leech Date: Tue, 27 Feb 2024 11:33:16 +0000 Subject: [PATCH] Update numeric.mjs --- lib/ui/locations/entries/numeric.mjs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/ui/locations/entries/numeric.mjs b/lib/ui/locations/entries/numeric.mjs index af95fec4d..6dda79fdf 100644 --- a/lib/ui/locations/entries/numeric.mjs +++ b/lib/ui/locations/entries/numeric.mjs @@ -71,8 +71,8 @@ function createFormatterNumberInput(entry) { } function onFocus(e, entry) { - e.target.value=parseFloat(entry.newValue || entry.value) - e.target.type='number'; + e.target.value = parseFloat(entry.newValue || entry.value) + e.target.type = 'number'; } function onBlur(e, entry) { @@ -93,14 +93,18 @@ function handleKeyUp(e, entry) { e.target.value = parseInt(e.target.value); } - if (!e.target.value) { + if (e.target.value === 0) { - delete entry.newValue - } else { + entry.newValue = 0; + } + else if (!e.target.value) { + entry.newValue = null; + } + else { entry.newValue = e.target.value; } - + entry.location.view?.dispatchEvent( new CustomEvent('valChange', { detail: entry }) );