cal.com icon indicating copy to clipboard operation
cal.com copied to clipboard

Incorrect recognition of the phone number

Open RainerZufall9393 opened this issue 2 years ago • 7 comments

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

RainerZufall9393 avatar Feb 24 '23 14:02 RainerZufall9393

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

Ashish0253 avatar May 23 '23 19:05 Ashish0253

Hey @Ashish0253 how exactly can I help you?

RainerZufall9393 avatar May 23 '23 20:05 RainerZufall9393

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 ??

Ashish0253 avatar May 24 '23 04:05 Ashish0253

@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.

RainerZufall9393 avatar May 24 '23 11:05 RainerZufall9393

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

Ashish0253 avatar May 24 '23 14:05 Ashish0253

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

Ashish0253 avatar May 26 '23 07:05 Ashish0253

@Ashish0253 Yes, the error is still there

RainerZufall9393 avatar May 26 '23 12:05 RainerZufall9393

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

ExplorerAadi avatar Feb 29 '24 20:02 ExplorerAadi