mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
BUG-2441: Currency input field auto-highlighting fixed (#2443)
This commit is contained in:
@@ -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,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user