BUG-2441: Currency input field auto-highlighting fixed (#2443)

This commit is contained in:
Jyft
2025-08-09 03:48:36 +03:00
committed by GitHub
parent 601a6a5a8f
commit faa6f50001
@@ -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,
);
}
},
),
),
),