diff --git a/ui/src/components/OperationPanel.jsx b/ui/src/components/OperationPanel.jsx index 7bf8172..a498961 100644 --- a/ui/src/components/OperationPanel.jsx +++ b/ui/src/components/OperationPanel.jsx @@ -258,6 +258,12 @@ function derive(current, edit, dp = 2) { new: fmtNum(next, dp), change: fmtNum(change, dp), pct: pct == null ? '—' : fmtNum(pct, 1), + // The same three as numbers, for anything that needs to compute with them. + // The strings above are grouped by toLocaleString, and parseFloat stops at + // the first separator -- "3,456,789" reads back as 3 -- so a caller that + // re-parsed the display got a plausible small number rather than an error. + // Nothing should have to know that; the numbers travel alongside. + n: { new: next, change, pct }, } out[edit.field] = edit.raw // keep what you typed exactly as typed return out @@ -442,9 +448,8 @@ function ScaleLedger({ currentTotals, scaleInputs, setScaleInputs, scalePlug, se // left units and price blank -- exactly the two numbers you need to see to // know whether you asked for a price change or a volume change. const numOf = (key, field) => { - const raw = derived[key]?.[field] - const n = parseFloat(raw) - return isFinite(n) ? n : null + const n = derived[key]?.n?.[field] + return n != null && isFinite(n) ? n : null } const outcome = (() => {