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

Props countryCodeEditable not working with United State (us)

Open Bdragon93 opened this issue 6 years ago • 8 comments

Hi, I have an issue when the country is us (United State) and I set countryCodeEditable is false like this:

 <PhoneInput country="us" countryCodeEditable={false} enableSearch />

But the country code can be removed and can not enter the new one. :(

inputphone

Did I miss something? Please help me take a look! TIA

Bdragon93 avatar Apr 22 '20 11:04 Bdragon93

This issue is for all countries which have 1 digit in country code. Screenshot from 2020-04-22 18-59-13

andrushkodmytro avatar Apr 22 '20 15:04 andrushkodmytro

It did not happen in my other repo with v2.12.0, but this version is not support TS :|

Bdragon93 avatar Apr 22 '20 16:04 Bdragon93

The same issue is happening with my code, and it is leading the other issue as well. Once I remove the country code it additionally adds country code twice.

KApilBD avatar Apr 23 '20 05:04 KApilBD

Same problem for me with US. @bl00mber any idea ?

raphaelnoguier avatar Apr 27 '20 09:04 raphaelnoguier

Can you send/suggest a failing test?

bl00mber avatar May 14 '20 13:05 bl00mber

I also face this issue. This issue can be seen in the demo (https://bl00mber.github.io/react-phone-input-2.html) as well with this configuration {"country":"us","countryCodeEditable": false}

farizsofyan avatar Jun 03 '20 08:06 farizsofyan

I believe this could be a quick fix for the issue until a PR gets merged.

<PhoneInput
  country='us'
  value={input}
  onKeyDown={(e) => {
    if ((e.which === 8 || e.which === 46) && input.length <= 1) e.preventDefault();
  }}
  onChange={(value) => {
    setInput(value);
  }}
  countryCodeEditable={false}
/>

MJSPollard avatar Jun 03 '20 19:06 MJSPollard

Thank you for the above, it works. A permanent fix should be rolled out though, the prop is pretty useless since the fix is pretty much at work for all cases.

zaidyahya avatar Jun 09 '20 15:06 zaidyahya