intl-tel-input icon indicating copy to clipboard operation
intl-tel-input copied to clipboard

[bug] with country flag in change moment

Open JackmanBR opened this issue 9 months ago • 6 comments

while i change the country in input field to Canada and i enter some number, the field automatically changes the flag from Canada to United States. This issue occurs with other countries which have same dialing code in '+1'. I see in official github and website that the issue also occurs.

JackmanBR avatar Mar 28 '25 17:03 JackmanBR

Hi, assign me to make a PR please!

successbyte avatar Apr 03 '25 07:04 successbyte

@JackmanBR are you sure you're typing a number with a Canadian area code? Can you give a specific example of a Canadian number that is changing the flag to another country?

jackocnr avatar Apr 03 '25 08:04 jackocnr

Hello, I discovered that it automatically changes based on the area code, but I couldn't find where to add other area codes, and I also noticed that the error occurs with other countries with code +1, no matter the number entered, it automatically selects the United States.

JackmanBR avatar Apr 03 '25 22:04 JackmanBR

As I checked it also detects Canadian area code. Actually, I do not have Canada's area codes but when you change the country to US and enter 506... as number it automatically changes to Canada.

successbyte avatar Apr 05 '25 11:04 successbyte

@successbyte Yup, because 506 is a Canadian area code. You can see a list of them here: https://github.com/jackocnr/intl-tel-input/blob/master/src/js/intl-tel-input/data.ts#L197

@JackmanBR as I said before, please give me a specific example of a number that when you type it, it selects the wrong flag.

jackocnr avatar Apr 05 '25 11:04 jackocnr

Yes, I adjusted some of its files and managed to put the local data.ts, so I'm adding more area codes manually from the countries as users report them in my application. Using the local data.ts is making things easier. Thank you very much for the feedback.

JackmanBR avatar Apr 05 '25 14:04 JackmanBR