Skip to content

Commit

Permalink
Merge pull request #1159 from simon-leech/null-numeric
Browse files Browse the repository at this point in the history
Numeric Inputs
  • Loading branch information
RobAndrewHurst authored Feb 27, 2024
2 parents 88e2fd2 + 0290b0a commit a2e6636
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/ui/locations/entries/numeric.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 })
);
Expand Down

0 comments on commit a2e6636

Please sign in to comment.