From 25a839bf888b6c0452529ec7114d31238b521605 Mon Sep 17 00:00:00 2001 From: Joe Knapper Date: Mon, 23 Feb 2026 17:48:26 +0000 Subject: [PATCH] Stringify 0 as axios treats it as "" Also add a check that we don't try to log(0) --- webapp/src/components/labThingsComponents/inputFromSchema.vue | 3 ++- webapp/src/mixins/labThingsMixins.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/webapp/src/components/labThingsComponents/inputFromSchema.vue b/webapp/src/components/labThingsComponents/inputFromSchema.vue index 5b251e2d..6caac19e 100644 --- a/webapp/src/components/labThingsComponents/inputFromSchema.vue +++ b/webapp/src/components/labThingsComponents/inputFromSchema.vue @@ -346,7 +346,8 @@ export default { } // Rounding to about 5 sig figs to stop weird javascript rounding. - const magnitude = Math.floor(Math.log10(Math.abs(newValue))); + const absVal = Math.abs(newValue); + const magnitude = absVal > 0 ? Math.floor(Math.log10(absVal)) : 0; const factor = 10 ** -(Math.floor(magnitude) - 4); this.internalValue = Math.round(newValue * factor) / factor; }, diff --git a/webapp/src/mixins/labThingsMixins.js b/webapp/src/mixins/labThingsMixins.js index 2b935492..4fcc4d1a 100644 --- a/webapp/src/mixins/labThingsMixins.js +++ b/webapp/src/mixins/labThingsMixins.js @@ -56,10 +56,10 @@ export default { "writeproperty", false, ); - // `false` fails because axios somehow eats it! + // `false` and 0 fail because axios turns it to "" // Other values should not be stringified or pydantic // can't parse them. - if (value === false || value === true) { + if (value === false || value === true || value === 0) { value = JSON.stringify(value); } await axios.put(url, value);