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

Calling `iti.setNumber` will focus input on iOS

Open MaartenPetiet opened this issue 7 months ago • 1 comments

Plugin version v25.3.1

Steps to reproduce Open this example sandbox on iOS 18.3 or lower https://tlqzfg.csb.app/

Expected behaviour The input should not be focused without user interaction.

Actual behaviour The second input (where intl-tel-input is loaded) will automatically focus.

Initialisation options No initialisation options are needed to reproduce. It happens when calling the iti.setNumber method.

In this example I call the iti.setNumber method directly, but normally this would be done after an async API call to prefill the data or after a reset fields button click, when it's not desirable that this input is automatically focused.

MaartenPetiet avatar Apr 30 '25 15:04 MaartenPetiet

FYI that I also saw this happening to a user in Safari 18.1.1 on a Macbook.

Working around it by manually disabling the input before using setNumber() and re-enabling it afterwards. This prevents Safari from focusing it. But yeah a real footgun for sure, especially if you're automatically calling setNumber() to re-format the input value on blur (in my case effectively prevented users from ever leaving the input after they had started editing it).

micah-redwood avatar May 19 '25 19:05 micah-redwood

Thanks for reporting this.

Here is the relevant code: https://github.com/jackocnr/intl-tel-input/blob/master/src/js/intl-tel-input.ts#L2130

I'm afraid I don't have time to look into this myself right now, but I'd welcome a pull request that fixes it.

jackocnr avatar Aug 22 '25 13:08 jackocnr

Fix released in v25.8.4.

jackocnr avatar Sep 02 '25 19:09 jackocnr