aboutsummaryrefslogtreecommitdiffstats
path: root/src/app.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-06-15 09:59:34 -0700
committerAdam Soltys <[email protected]>2026-06-15 09:59:34 -0700
commita7b17ffd165e28be2bb707ad7679c993fd17a4d6 (patch)
tree2321f023d7586809529b484915212656e2738eaf /src/app.js
parent59359581ae8a25a6a55f9e9122b94ceca20e186b (diff)
downloadcoinosv3-a7b17ffd165e28be2bb707ad7679c993fd17a4d6.tar.gz
coinosv3-a7b17ffd165e28be2bb707ad7679c993fd17a4d6.zip
Normalize amount input out of scientific notation
Chrome's number input emits "1e-8"-style values when stepping the tiny BTC step; convert any scientific-notation value back to a plain decimal string on input. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Diffstat (limited to 'src/app.js')
-rw-r--r--src/app.js14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/app.js b/src/app.js
index 208af57..259c06f 100644
--- a/src/app.js
+++ b/src/app.js
@@ -632,7 +632,19 @@ function sendForm() {
value: s.max
? (s.unit === 'sats' ? String(estimatedMaxSats()) : fmtBtc(estimatedMaxSats()))
: s.amount,
- onInput: (e) => (s.amount = e.target.value),
+ onInput: (e) => {
+ let v = e.target.value;
+ // Chrome emits scientific notation (e.g. "1e-8") when stepping tiny
+ // BTC amounts — normalize it back to a plain decimal string.
+ if (v && /e/i.test(v)) {
+ const n = Number(v);
+ if (isFinite(n)) {
+ v = s.unit === 'sats' ? String(Math.round(n)) : n.toFixed(8).replace(/\.?0+$/, '');
+ e.target.value = v;
+ }
+ }
+ s.amount = v;
+ },
}),
h(
'div',