The personal finance app for everyone (by everyone)
Ruby
Skip reformatting blank amount fields on currency change
Claudeef4750c2c578
diff --git a/app/javascript/controllers/money_field_controller.js b/app/javascript/controllers/money_field_controller.jsindex ac77008e5b..686ca713a0 100644--- a/app/javascript/controllers/money_field_controller.js+++ b/app/javascript/controllers/money_field_controller.js@@ -16,9 +16,12 @@ export default class extends Controller {new CurrenciesService().get(currency).then((currency) => {this.amountTarget.step = currency.step;- const parsedAmount = parseLocaleFloat(this.amountTarget.value);- if (Number.isFinite(parsedAmount)) {- this.amountTarget.value = parsedAmount.toFixed(currency.default_precision);+ const rawValue = this.amountTarget.value.trim();+ if (rawValue !== "") {+ const parsedAmount = parseLocaleFloat(rawValue);+ if (Number.isFinite(parsedAmount)) {+ this.amountTarget.value = parsedAmount.toFixed(currency.default_precision);+ }}this.symbolTarget.innerText = currency.symbol;