intl_phone_number_input icon indicating copy to clipboard operation
intl_phone_number_input copied to clipboard

After entering a valid number the cusor position is set to the number start [Android]

Open jimmyff opened this issue 4 years ago • 13 comments
trafficstars

As soon as the number successfully validates the cursor jumps to the start of the text input. This makes it hard for someone to amend a possible mistake as well as being a little disorientating.

jimmyff avatar Oct 12 '21 16:10 jimmyff

Also with a country like Bulgaria, where numbers can be 7 or 8 digits, as you're enter your 7th digit it moves your position back to the start, making it easy to accidentally enter the 8 digit at the start

jimmyff avatar Oct 12 '21 16:10 jimmyff

this is also the case when using autoValidateMode: AutovalidateMode.disabled

jimmyff avatar Oct 12 '21 16:10 jimmyff

Hello Everyone Is there any updates on this issue? I am facing it too when passing initial value to the InternationalPhoneNumberInput widget

noororfahly13 avatar Nov 02 '21 07:11 noororfahly13

The same issue appears to occur in web. Using release 0.7.0+2 and Flutter version 2.5.3

Ashirg-ch avatar Nov 05 '21 14:11 Ashirg-ch

any update on this?

AhmedKhattab95 avatar Feb 03 '22 14:02 AhmedKhattab95

While this might be unintended, I think it is actually beneficial to retain this behaviour because the cursors moves to the front and the user is unable to add more digits by mistake.

The downside of this is if they want to change it they must tap on the end to get the cursor position to the final digit.

ken-ng-esotec avatar Feb 22 '22 04:02 ken-ng-esotec

Is there any updates on this issue?

antoniok90 avatar Mar 10 '22 12:03 antoniok90

Hey, any news ? I am facing the same issue with italian numbers that should be able to go up to 12 digits but the cursor gets resetted to its start position after a maximum of 11. It's really inconvenient for our users

arceusVen1 avatar May 04 '22 15:05 arceusVen1

Same problem with Finnish phone numbers

vanosidor avatar Jul 06 '22 08:07 vanosidor

Hey,

I have solved this problem by adding the line below in the project file (widgets/input_widget.dart)

Just add

controller!.selection = TextSelection.collapsed(offset: phoneNumber.length);

under

controller!.text = widget.formatInput
            ? phoneNumber
            : phoneNumber.replaceAll(RegExp(r'[^\d+]'), '');

sametciftcidev avatar Feb 22 '23 10:02 sametciftcidev

Hey,

I have solved this problem by adding the line below in the project file (widgets/input_widget.dart)

Just add

controller!.selection = TextSelection.collapsed(offset: phoneNumber.length);

under

controller!.text = widget.formatInput
            ? phoneNumber
            : phoneNumber.replaceAll(RegExp(r'[^\d+]'), '');

This works. Thank you

oltoch avatar Mar 27 '23 13:03 oltoch

In onInputChanged method, add the following line

numCont.selection = TextSelection.collapsed(offset: numCont.text.length);

and numCont is your own TextEditingController.

Here is the full code:

onInputChanged: (PhoneNumber number) {
        numCont.selection = TextSelection.collapsed(offset: numCont.text.length);
        },

Shehzad1Dev avatar May 03 '23 06:05 Shehzad1Dev

Hey,

I have solved this problem by adding the line below in the project file (widgets/input_widget.dart)

Just add

controller!.selection = TextSelection.collapsed(offset: phoneNumber.length);

under

controller!.text = widget.formatInput
            ? phoneNumber
            : phoneNumber.replaceAll(RegExp(r'[^\d+]'), '');

After the recent flutter upgrade to v3.10.0 and after, the cursor starts to misbehave by going back to the beginning like it used to. Anyone have any idea why the recent flutter upgrade is making that happen?

oltoch avatar May 25 '23 19:05 oltoch