natintosh / intl_phone_number_input

MIT License
166 stars 510 forks source link

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

Open jimmyff opened 3 years ago

jimmyff commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

noororfahly13 commented 3 years ago

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

Ashirg-ch commented 3 years ago

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

AhmedKhattab95 commented 2 years ago

any update on this?

ken-ng-esotec commented 2 years ago

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.

antoniok90 commented 2 years ago

Is there any updates on this issue?

arceusVen1 commented 2 years ago

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

vanosidor commented 2 years ago

Same problem with Finnish phone numbers

sametciftcidev commented 1 year ago

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+]'), '');
oltoch commented 1 year ago

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

Shehzad1Dev commented 1 year ago

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);
        },
oltoch commented 1 year ago

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?