calcom / cal.com

Scheduling infrastructure for absolutely everyone.
https://cal.com
Other
31.41k stars 7.6k forks source link

Incorrect recognition of the phone number #7370

Open RainerZufall9393 opened 1 year ago

RainerZufall9393 commented 1 year ago

When I use the autofill function for my phone number, it is not inserted correctly. It is a German number, but it is inserted in the wrong format.

https://user-images.githubusercontent.com/126205884/221208300-d23ab075-678c-47e9-b6ee-a0c0b6e31be5.MP4

Ashish0253 commented 1 year ago

@RainerZufall9393 can you help me reproduce this error as the language on your screen is not English

RainerZufall9393 commented 1 year ago

Hey @Ashish0253 how exactly can I help you?

Ashish0253 commented 1 year ago

Thanks for asking @RainerZufall9393 but I have reproduced this error and I think it's taking the country code of your current location, were you in Germany when you filled in your number ??

RainerZufall9393 commented 1 year ago

@Ashish0253 Yes exactly, was in Germany at the time. In fact, the problem is that the country code is not recognized in this example.

At the beginning of my number is +49 which is removed when inserting. That means only the rest of the number is inserted (17672868292), without the +49 at the beginning.

For this reason +1 is recognized as country code by the form, because the number continues after the +49 with a 1.

Ashish0253 commented 1 year ago

@RainerZufall9393 Thankyou for explaining the problem, I will try to solve it

Ashish0253 commented 1 year ago

@RainerZufall9393 Can you please try again to fill your number and confirm whether the error is still there

RainerZufall9393 commented 1 year ago

@Ashish0253 Yes, the error is still there

ExplorerAadi commented 6 months ago

Yes this has been a common issue with react-phone-input-2 library that we are using that I have seen in my previous projects too but it's hard to fix this issue since that library does not expose a paste event handler.

Although one way to achieve the desired use case you want @RainerZufall9393 with just a bit of extra effort is to select all in the input field before pasting a number with country code already present. Here is a demo:

https://github.com/calcom/cal.com/assets/52901335/9ceea554-35a6-4835-97f6-f3ddc804b679