A local-first personal finance app
fix decimal input in amount input boxes (#5831)
Matt Fiddamanfa14cbb697fe
diff --git a/packages/loot-core/src/shared/rules.ts b/packages/loot-core/src/shared/rules.tsindex cac2e07743..24dd2fbf82 100644--- a/packages/loot-core/src/shared/rules.ts+++ b/packages/loot-core/src/shared/rules.ts@@ -3,7 +3,12 @@ import { t } from 'i18next';import { FieldValueTypes, RuleConditionOp } from '../types/models';-import { integerToAmount, amountToInteger, currencyToAmount } from './util';+import {+ integerToAmount,+ amountToInteger,+ currencyToAmount,+ getNumberFormat,+} from './util';// For now, this info is duplicated from the backend. Figure out how// to share it later.@@ -374,10 +379,22 @@ export function makeValue(value, cond) {switch (cond.type) {case 'number': {if (cond.op !== 'isbetween') {+ const stringValue = String(value);+ const { decimalSeparator } = getNumberFormat();++ // preserve trailing decimal separator to allow decimal input during typing+ if (stringValue && stringValue.endsWith(decimalSeparator)) {+ return {+ ...cond,+ error: null,+ value: stringValue,+ };+ }+return {...cond,error: null,- value: value ? currencyToAmount(String(value)) || 0 : 0,+ value: value ? currencyToAmount(stringValue) || 0 : 0,};}break;diff --git a/upcoming-release-notes/5831.md b/upcoming-release-notes/5831.mdnew file mode 100644index 0000000000..edefb44b40--- /dev/null+++ b/upcoming-release-notes/5831.md@@ -0,0 +1,6 @@+---+category: Bugfix+authors: [matt-fidd]+---++Allow decimals numbers to be typed into amount filter