From faa6f5000192c5af817ca3884f8a9128eebd6163 Mon Sep 17 00:00:00 2001 From: Jyft Date: Sat, 9 Aug 2025 01:48:36 +0100 Subject: [PATCH] BUG-2441: Currency input field auto-highlighting fixed (#2443) --- .../receive/widgets/currency_input_field.dart | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/src/screens/receive/widgets/currency_input_field.dart b/lib/src/screens/receive/widgets/currency_input_field.dart index 83c5f9836..048b1d473 100644 --- a/lib/src/screens/receive/widgets/currency_input_field.dart +++ b/lib/src/screens/receive/widgets/currency_input_field.dart @@ -200,8 +200,18 @@ class CurrencyAmountTextField extends StatelessWidget { color: Theme.of(context).colorScheme.onSurfaceVariant, ), validator: isAmountEditable ? currencyValueValidator : null, - onChanged: (value) => amountController.text = - value.replaceAll(',', '.').withMaxDecimals(selectedCurrencyDecimals), + onChanged: (value) { + final sanitized = + value.replaceAll(',', '.').withMaxDecimals(selectedCurrencyDecimals); + if (sanitized != amountController.text) { + // Update text while preserving a sane cursor position to avoid auto-selection + amountController.value = amountController.value.copyWith( + text: sanitized, + selection: TextSelection.collapsed(offset: sanitized.length), + composing: TextRange.empty, + ); + } + }, ), ), ),