diff options
| author | Adam Soltys <[email protected]> | 2026-06-15 09:59:34 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-06-15 09:59:34 -0700 |
| commit | a7b17ffd165e28be2bb707ad7679c993fd17a4d6 (patch) | |
| tree | 2321f023d7586809529b484915212656e2738eaf /src | |
| parent | 59359581ae8a25a6a55f9e9122b94ceca20e186b (diff) | |
| download | coinosv3-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')
| -rw-r--r-- | src/app.js | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -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', |
