File tree Expand file tree Collapse file tree
features/receive/ui/screens Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,10 +66,13 @@ class AmountInputFormatter extends TextInputFormatter {
6666 // If characters were removed (by leading zero logic or regex truncation)
6767 if (charsRemovedByLeadingZeroLogic > 0 ) {
6868 // Leading zeros removed: keep cursor at original position
69- newOffset = oldValue.selection.baseOffset;
69+ newOffset = oldValue.selection.baseOffset. clamp ( 0 , validText.length) ;
7070 } else if (charsRemovedByRegex > 0 ) {
7171 // Text truncated by regex (invalid chars or excess decimals): move to end
7272 newOffset = validText.length;
73+ } else if (oldValue.selection.baseOffset == - 1 ) {
74+ // Field was unfocused, preserve the new offset from the caller (dial pad)
75+ newOffset = newValue.selection.baseOffset.clamp (0 , validText.length);
7376 } else {
7477 // Normal case: adjust cursor by the text length difference
7578 final lengthDifference = validText.length - oldValue.text.length;
Original file line number Diff line number Diff line change @@ -59,6 +59,18 @@ class _AmountPageState extends State<AmountPage> {
5959 }
6060 });
6161 _amountFocusNode = FocusNode ();
62+
63+ // When focus changes, reset selection if unfocused
64+ _amountFocusNode.addListener (() {
65+ if (! _amountFocusNode.hasFocus) {
66+ // Field lost focus, reset selection to end without showing cursor
67+ final currentText = _amountController.text;
68+ _amountController.value = TextEditingValue (
69+ text: currentText,
70+ selection: TextSelection .collapsed (offset: currentText.length),
71+ );
72+ }
73+ });
6274 }
6375
6476 @override
You can’t perform that action at this time.
0 commit comments