react-native-phone-input icon indicating copy to clipboard operation
react-native-phone-input copied to clipboard

Cannot remove multi-digit country codes with delete key, with autoformat

Open ziaulrehman40 opened this issue 6 years ago • 2 comments

Screen Recording 2019-07-02 at 12 19 AM

As seen in this gif, i am actually trying to delete digits from country code when country code is multi digit, it does not seem to be able to remove them. But works fine with single digit country codes.

This issue only appears when auto-format is enabled, and i seem to be able to select the country code with double tap and can remove it than, but not normally.

I am testing on iOS simulator(iphone Xs max) as i am still in dev mode. Version of library: 0.2.2 RN: 0.59.9

ziaulrehman40 avatar Jul 02 '19 07:07 ziaulrehman40

Same happening with RN 0.60.1. Removing "autoFormat" fixed the issue.

m4manjesh avatar Nov 27 '19 10:11 m4manjesh

Hey guys. I know I am pretty late here but I recently started using this library and I also faced the same issue and I resolved this with a simple listener on onChangePhoneNumber, simply create a boolean state and check the length of your text and toggle auto formatting accordingly. Refer below:

const [autoFormatPhoneNumber, setAutoFormatPhoneNumber] = useState(true); <PhoneInput textStyle={{color: 'black', fontSize: 17}} ref={phoneNumber} onChangePhoneNumber={text => text.length < 5 ? setAutoFormatPhoneNumber(false) : setAutoFormatPhoneNumber(true)} autoFormat={autoFormatPhoneNumber} />

Hope this helps someone.

KawaljeetSBagga avatar May 15 '20 06:05 KawaljeetSBagga