A local-first personal finance app
[AI] Mobile: live value tracking (#7774)
Matiss Janis Aboltins4f40defe9eb6
diff --git a/packages/desktop-client/src/components/mobile/transactions/FocusableAmountInput.tsx b/packages/desktop-client/src/components/mobile/transactions/FocusableAmountInput.tsxindex bc0620aacd..d571ad4465 100644--- a/packages/desktop-client/src/components/mobile/transactions/FocusableAmountInput.tsx+++ b/packages/desktop-client/src/components/mobile/transactions/FocusableAmountInput.tsx@@ -190,9 +190,11 @@ export const FocusableAmountInput = memo(function FocusableAmountInput({buttonProps,onFocus,onBlur,+ onChangeValue,...props}: FocusableAmountInputProps) {const [isNegative, setIsNegative] = useState(true);+ const [liveValue, setLiveValue] = useState(Math.abs(value));const maybeApplyNegative = (amount: number, negative: boolean) => {const absValue = Math.abs(amount);@@ -203,6 +205,15 @@ export const FocusableAmountInput = memo(function FocusableAmountInput({props.onUpdateAmount?.(maybeApplyNegative(amount, negative));};+ const handleChangeValue = (text: string) => {+ setLiveValue(currencyToAmount(text) || 0);+ onChangeValue?.(text);+ };++ useEffect(() => {+ setLiveValue(Math.abs(value));+ }, [value]);+useEffect(() => {if (sign) {setIsNegative(sign === '-');@@ -227,10 +238,11 @@ export const FocusableAmountInput = memo(function FocusableAmountInput({value={value}onFocus={onFocus}onBlur={onBlur}+ onChangeValue={handleChangeValue}onUpdateAmount={amount => onUpdateAmount(amount, isNegative)}focused={focused && !disabled}style={{- ...makeAmountFullStyle(value, {+ ...makeAmountFullStyle(maybeApplyNegative(liveValue, isNegative), {zeroColor: isNegative ? theme.numberNegative : theme.numberNeutral,positiveColor: theme.numberPositive,negativeColor: theme.numberNegative,diff --git a/upcoming-release-notes/7774.md b/upcoming-release-notes/7774.mdnew file mode 100644index 0000000000..b1c4a9efa2--- /dev/null+++ b/upcoming-release-notes/7774.md@@ -0,0 +1,6 @@+---+category: Bugfix+authors: [MatissJanis]+---++Mobile: add live value tracking for user input in mobile transactions.