BUG-2441: Currency input field auto-highlighting fixed (#2443)
Jyft committed
Aug 9, 2025 at 01:48 UTC
faa6f5000192c5af817ca3884f8a9128eebd6163
1 file changed
+12
-2
lib/src/screens/receive/widgets/currency_input_field.dart
+12
-2
@@ -200,8 +200,18 @@ class CurrencyAmountTextField extends StatelessWidget {
200
color: Theme.of(context).colorScheme.onSurfaceVariant,
201
),
202
validator: isAmountEditable ? currencyValueValidator : null,
203
- onChanged: (value) => amountController.text =
204
- value.replaceAll(',', '.').withMaxDecimals(selectedCurrencyDecimals),
203
+ onChanged: (value) {
204
+ final sanitized =
205
+ value.replaceAll(',', '.').withMaxDecimals(selectedCurrencyDecimals);
206
+ if (sanitized != amountController.text) {
207
+ // Update text while preserving a sane cursor position to avoid auto-selection
208
+ amountController.value = amountController.value.copyWith(
209
+ text: sanitized,
210
+ selection: TextSelection.collapsed(offset: sanitized.length),
211
+ composing: TextRange.empty,
212
+ );
213
+ }
214
+ },
215
),
216
),
217
),